From 2d4f203b43d3e81a3fbbdd0c4e3db274ef11c6b3 Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Mon, 18 Dec 2023 13:21:20 +0800 Subject: [PATCH] [opt] wiki tag --- scripts/helpers/category_color.js | 23 ++++++++++++++++++----- source/css/_layout/list.styl | 4 ++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/scripts/helpers/category_color.js b/scripts/helpers/category_color.js index f16fe19..e55f55e 100644 --- a/scripts/helpers/category_color.js +++ b/scripts/helpers/category_color.js @@ -1,9 +1,22 @@ 'use strict'; hexo.extend.helper.register('category_color', function(cat){ - const cfg = hexo.theme.config; - if (cfg.article.category_color && cfg.article.category_color[cat]) { - return ' style="color:' + cfg.article.category_color[cat] + '"'; + const { config } = hexo.theme + const color = config.article.category_color[cat] + if (color) { + var textColor = color + if (color.startsWith('#')) { + textColor = color + } else { + textColor = '#' + color + } + var bgColor = textColor + if (textColor.length == (1+3)) { // #fff + bgColor += '2' + } else if (textColor.length == (1+6)) { // #ffffff + bgColor += '20' + } + return ` style="--text-p3:${textColor};--theme-block:${bgColor}"`; } - return ''; -}); + return '' +}) diff --git a/source/css/_layout/list.styl b/source/css/_layout/list.styl index 7ac9284..e8e742b 100644 --- a/source/css/_layout/list.styl +++ b/source/css/_layout/list.styl @@ -162,6 +162,10 @@ flex: 1 overflow: hidden word-wrap: break-word + .cap + background: var(--theme-block) + padding: 2px 4px + border-radius: 2px p:last-child margin-bottom: 0 .cap+.cap