From 65ce616542eaf59bd4d0ba5022a436da72dd422a Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Wed, 2 Mar 2022 14:50:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96heti=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _config.yml | 6 +++--- layout/_partial/main/post_list/post_card.ejs | 6 +++++- layout/_partial/scripts/index.ejs | 3 +++ layout/post.ejs | 8 ++++++-- source/js/main.js | 10 ++++++++++ 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/_config.yml b/_config.yml index 8497d2b..b39dcb2 100755 --- a/_config.yml +++ b/_config.yml @@ -248,11 +248,11 @@ plugins: enable: true css: https://unpkg.com/swiper@6/swiper-bundle.min.css js: https://unpkg.com/swiper@6/swiper-bundle.min.js - - + + # 赫蹏 (Heti) - 专为中文网页内容设计的排版样式增强 # https://github.com/sivan/heti - heti: + heti: enable: false css: https://unpkg.com/heti/umd/heti.min.css js: https://unpkg.com/heti/umd/heti-addon.min.js diff --git a/layout/_partial/main/post_list/post_card.ejs b/layout/_partial/main/post_list/post_card.ejs index a6bbe90..285bd6f 100755 --- a/layout/_partial/main/post_list/post_card.ejs +++ b/layout/_partial/main/post_list/post_card.ejs @@ -40,7 +40,11 @@ function div_default() { el += ''; // 摘要 - el += '
'; + el += '
'; el += '

'; if (post.excerpt) { el += strip_html(post.excerpt); diff --git a/layout/_partial/scripts/index.ejs b/layout/_partial/scripts/index.ejs index 2f71e2d..77733d6 100644 --- a/layout/_partial/scripts/index.ejs +++ b/layout/_partial/scripts/index.ejs @@ -124,6 +124,9 @@ if ('<%- theme.plugins.fancybox.enable %>' == 'true') { stellar.plugins.fancybox = Object.assign(<%- JSON.stringify(theme.plugins.fancybox) %>); } + if ('<%- theme.plugins.heti.enable %>' == 'true') { + stellar.plugins.heti = Object.assign(<%- JSON.stringify(theme.plugins.heti) %>); + } diff --git a/layout/post.ejs b/layout/post.ejs index e1ddffd..43c5270 100755 --- a/layout/post.ejs +++ b/layout/post.ejs @@ -13,10 +13,14 @@ function layoutTitle() { return ''; } } +let post = page; +let heti = ''; +if (theme.plugins.heti && theme.plugins.heti.enable) { + heti = ' heti'; +} %> -<% let post = page; %> <%- partial('_partial/main/navbar/breadcrumb') %> -

<%- scrollreveal() %>'> +
<%- scrollreveal() %>'> <%- layoutTitle() %> <%- post.content %> <%- partial('_partial/main/article/article_footer') %> diff --git a/source/js/main.js b/source/js/main.js index 721cb4b..46aed77 100644 --- a/source/js/main.js +++ b/source/js/main.js @@ -296,3 +296,13 @@ if (stellar.plugins.fancybox) { }) } } + +// heti +if (stellar.plugins.heti) { + stellar.loadCSS(stellar.plugins.heti.css); + stellar.loadScript(stellar.plugins.heti.js, { defer: true }).then(function () { + const heti = new Heti('.heti p'); + heti.autoSpacing(); + stellar.plugins.heti.enable = false; + }); +}