From 551c764a69bbea740665f4c9696cf3b08a0ee79e Mon Sep 17 00:00:00 2001 From: Amio Date: Sat, 6 Jul 2019 16:04:16 +0800 Subject: [PATCH] Update preview --- preview/preview.md | 1 + preview/serve.js | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/preview/preview.md b/preview/preview.md index 5350f51..a430b04 100644 --- a/preview/preview.md +++ b/preview/preview.md @@ -22,6 +22,7 @@ |![](/style/standard/f2a) | [/style/standard/f2a](/style/standard/f2a) | |![](/license/Apache-2.0/blue) | [/license/Apache-2.0/blue](/license/Apache-2.0/blue) | |![](/Language/Swift%203.0.1/orange) | [/Language/Swift%203.0.1/orange](/Language/Swift%203.0.1/orange) | +|![](/labelColor/badge/yellow?icon=chrome&labelColor=red) ## Flat Style diff --git a/preview/serve.js b/preview/serve.js index 4e8a70c..0ee6858 100644 --- a/preview/serve.js +++ b/preview/serve.js @@ -1,3 +1,4 @@ +const fs = require('fs') const path = require('path') const http = require('http') const url = require('url') @@ -9,16 +10,16 @@ const icons = require('../test/assets/icon-data-uri.js') const serveBadge = (req, res) => { const { pathname, query } = url.parse(req.url) - const { style, icon, iconWidth } = qs.parse(query) + const { label, style, icon, iconWidth, labelColor } = qs.parse(query) const [ subject, status, color ] = pathname.split('/').splice(1) .map(s => qs.unescape(s)) res.statusCode = 200 res.setHeader('Content-Type', 'image/svg+xml;charset=utf-8') - res.end(badgen({ subject, status, color, style, icon: icons[icon], iconWidth })) + res.end(badgen({ label, labelColor, subject, status, color, style, icon: icons[icon], iconWidth })) } -const md = path.join(__dirname, 'preview.md') +const md = fs.readFileSync(path.join(__dirname, 'preview.md'), 'utf8') const inlineCSS = ` body { color: #333; padding-bottom: 5em; max-width: 800px } a { text-decoration: none; color: #06D }