From c5e975e555614d4fe646b755325b8c5b8a3be1e4 Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Tue, 7 Jun 2022 13:19:56 +0800 Subject: [PATCH] highlightjs_theme --- _config.yml | 5 +++-- layout/_partial/head.ejs | 5 +++++ source/css/_common/highlight.styl | 11 +++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/_config.yml b/_config.yml index b2ec401..901449d 100755 --- a/_config.yml +++ b/_config.yml @@ -139,7 +139,7 @@ comments: js: https://unpkg.com/@waline/client@v2/dist/waline.js css: https://unpkg.com/@waline/client@v2/dist/waline.css # Waline server address url, you should set this to your own link - serverURL: + serverURL: # If false, comment count will only be displayed in post page, not in home page commentCount: true @@ -302,7 +302,7 @@ plugins: enable: false css: https://unpkg.com/heti/umd/heti.min.css js: https://unpkg.com/heti/umd/heti-addon.min.js - + # MathJax # 需在Markdown文件开头加入mathjax: true # 推荐使用Pandoc: npm uninstall hexo-renderer-marked --save & npm install hexo-renderer-pandoc --save @@ -321,6 +321,7 @@ style: background: https://fastly.jsdelivr.net/gh/cdn-x/placeholder@1.0.2/avatar/round/rainbow64@3x.webp codeblock: scrollbar: 4px + highlightjs_theme: https://fastly.jsdelivr.net/gh/highlightjs/cdn-release@11.5.0/build/styles/atom-one-dark.min.css default: avatar: https://fastly.jsdelivr.net/gh/cdn-x/placeholder@1.0.1/avatar/round/3442075.svg diff --git a/layout/_partial/head.ejs b/layout/_partial/head.ejs index 6c894be..9b02e82 100755 --- a/layout/_partial/head.ejs +++ b/layout/_partial/head.ejs @@ -82,6 +82,11 @@ function og_args() { <%- favicon_tag(config.favicon) %> <% } %> + <% if (config.highlight && config.highlight.enable == true && config.highlight.hljs == true) { %> + <%- css(theme.style.codeblock.highlightjs_theme) %> + <% } %> + + <% if (config.inject && config.inject.head){ %> <% (config.inject.head||[]).forEach(function(item){ %> <%- item %> diff --git a/source/css/_common/highlight.styl b/source/css/_common/highlight.styl index 96c1b11..dbbe6d6 100644 --- a/source/css/_common/highlight.styl +++ b/source/css/_common/highlight.styl @@ -78,6 +78,17 @@ article.md .highlight table:not([class]) border-collapse: collapse + +article.md pre + >.caption + color: var(--text-p3) + >.hljs + padding: 1rem + border-radius: $border-block + border: 1px solid var(--block-border) + line-height: 1.5 + box-sizing: border-box + article.md .highlight .code vertical-align: top