优化heti配置

This commit is contained in:
xaoxuu 2022-03-02 14:50:45 +08:00
parent 724d23ca5c
commit 65ce616542
5 changed files with 27 additions and 6 deletions

View File

@ -248,11 +248,11 @@ plugins:
enable: true enable: true
css: https://unpkg.com/swiper@6/swiper-bundle.min.css css: https://unpkg.com/swiper@6/swiper-bundle.min.css
js: https://unpkg.com/swiper@6/swiper-bundle.min.js js: https://unpkg.com/swiper@6/swiper-bundle.min.js
# 赫蹏 (Heti) - 专为中文网页内容设计的排版样式增强 # 赫蹏 (Heti) - 专为中文网页内容设计的排版样式增强
# https://github.com/sivan/heti # https://github.com/sivan/heti
heti: heti:
enable: false enable: false
css: https://unpkg.com/heti/umd/heti.min.css css: https://unpkg.com/heti/umd/heti.min.css
js: https://unpkg.com/heti/umd/heti-addon.min.js js: https://unpkg.com/heti/umd/heti-addon.min.js

View File

@ -40,7 +40,11 @@ function div_default() {
el += '</h2>'; el += '</h2>';
// 摘要 // 摘要
el += '<div class="excerpt heti">'; el += '<div class="excerpt';
if (theme.plugins.heti && theme.plugins.heti.enable) {
el += ' heti';
}
el += '">';
el += '<p>'; el += '<p>';
if (post.excerpt) { if (post.excerpt) {
el += strip_html(post.excerpt); el += strip_html(post.excerpt);

View File

@ -124,6 +124,9 @@
if ('<%- theme.plugins.fancybox.enable %>' == 'true') { if ('<%- theme.plugins.fancybox.enable %>' == 'true') {
stellar.plugins.fancybox = Object.assign(<%- JSON.stringify(theme.plugins.fancybox) %>); 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) %>);
}
</script> </script>
<!-- required --> <!-- required -->

View File

@ -13,10 +13,14 @@ function layoutTitle() {
return ''; return '';
} }
} }
let post = page;
let heti = '';
if (theme.plugins.heti && theme.plugins.heti.enable) {
heti = ' heti';
}
%> %>
<% let post = page; %>
<%- partial('_partial/main/navbar/breadcrumb') %> <%- partial('_partial/main/navbar/breadcrumb') %>
<article class='content heti md <%- post.layout %><%- post.indent ? ' indent' : '' %><%- scrollreveal() %>'> <article class='content<%- heti %> md <%- post.layout %><%- post.indent ? ' indent' : '' %><%- scrollreveal() %>'>
<%- layoutTitle() %> <%- layoutTitle() %>
<%- post.content %> <%- post.content %>
<%- partial('_partial/main/article/article_footer') %> <%- partial('_partial/main/article/article_footer') %>

View File

@ -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;
});
}