[opt] wiki tag

This commit is contained in:
xaoxuu 2023-12-18 13:21:20 +08:00
parent b717668ab3
commit 2d4f203b43
2 changed files with 22 additions and 5 deletions

View File

@ -1,9 +1,22 @@
'use strict'; 'use strict';
hexo.extend.helper.register('category_color', function(cat){ hexo.extend.helper.register('category_color', function(cat){
const cfg = hexo.theme.config; const { config } = hexo.theme
if (cfg.article.category_color && cfg.article.category_color[cat]) { const color = config.article.category_color[cat]
return ' style="color:' + cfg.article.category_color[cat] + '"'; if (color) {
var textColor = color
if (color.startsWith('#')) {
textColor = color
} else {
textColor = '#' + color
} }
return ''; 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 ''
})

View File

@ -162,6 +162,10 @@
flex: 1 flex: 1
overflow: hidden overflow: hidden
word-wrap: break-word word-wrap: break-word
.cap
background: var(--theme-block)
padding: 2px 4px
border-radius: 2px
p:last-child p:last-child
margin-bottom: 0 margin-bottom: 0
.cap+.cap .cap+.cap