diff --git a/_config.yml b/_config.yml index 2c0626e..f29a09c 100755 --- a/_config.yml +++ b/_config.yml @@ -8,6 +8,10 @@ stellar: ######## head tags ######## +preconnect: + # - https://gcore.jsdelivr.net + # - https://unpkg.com + open_graph: enable: true twitter_id: # for open_graph meta @@ -353,7 +357,7 @@ plugins: # 需在Markdown文件开头加入mathjax: true # 推荐使用Pandoc: npm uninstall hexo-renderer-marked --save & npm install hexo-renderer-pandoc --save mathjax: - enable: true + # set to enable in page's front-matter js: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js?config=TeX-AMS-MML_HTMLorMML # Katex - The fastest math typesetting library for the web @@ -361,7 +365,7 @@ plugins: # https://github.com/KaTeX/KaTeX # 使用 hexo-renderer-markdown-it-plus 作为公式渲染器:npm uninstall hexo-renderer-marked --save npm install hexo-renderer-markdown-it-plus --save katex: - enable: false + # set to enable in page's front-matter min_css: min_js: auto_render_min_js: @@ -376,7 +380,8 @@ plugins: # B -->|option 2| C(Section C) # ``` mermaid: - enable: true + # set to enable in page's front-matter + style_optimization: false # use custom style in stellar # js: https://unpkg.com/mermaid@9.0.0/dist/mermaid.min.js js: https://cdn.jsdelivr.net/npm/mermaid@v9/dist/mermaid.min.js # Available themes: default | dark | forest | neutral diff --git a/layout/_partial/head.ejs b/layout/_partial/head.ejs index a3a06d9..6e3d4f8 100755 --- a/layout/_partial/head.ejs +++ b/layout/_partial/head.ejs @@ -67,18 +67,38 @@ function og_args() { } return Object.assign(args, page.open_graph); } + +function preconnect() { + var el = ''; + for (let href of (theme.preconnect || [])) { + el += ``; + } + return el; +} + +function custom_inject() { + var el = ''; + for (let item of (config.inject?.head || [])) { + el += item; + } + for (let item of (theme.inject?.head || [])) { + el += item; + } + for (let item of (page.inject?.head || [])) { + el += item; + } + return el; +} + %> + - <%- meta_generator() %> - + <%- generate_robots() %> - + <%- meta_generator() %> - - - - + <%- preconnect() %> @@ -115,16 +135,6 @@ function og_args() { <%- css(theme.style.codeblock.highlightjs_theme) %> <% } %> - <% if (theme.plugins.katex && theme.plugins.katex.enable) { %> - <%- theme.plugins.katex.min_css %> - <%- theme.plugins.katex.min_js %> - <%- theme.plugins.katex.auto_render_min_js %> - <% } %> - - - <% if (config.inject && config.inject.head){ %> - <% (config.inject.head||[]).forEach(function(item){ %> - <%- item %> - <% }) %> - <% } %> + <%- partial('plugins/parser/head') %> + <%- custom_inject() %> diff --git a/layout/_partial/plugins/parser/head.ejs b/layout/_partial/plugins/parser/head.ejs new file mode 100644 index 0000000..77aca89 --- /dev/null +++ b/layout/_partial/plugins/parser/head.ejs @@ -0,0 +1,3 @@ +<% if (page.katex == true) { %> + <%- partial('katex/head') %> +<% } %> \ No newline at end of file diff --git a/layout/_partial/plugins/parser/katex/head.ejs b/layout/_partial/plugins/parser/katex/head.ejs new file mode 100644 index 0000000..b34197e --- /dev/null +++ b/layout/_partial/plugins/parser/katex/head.ejs @@ -0,0 +1,3 @@ +<% if (theme.plugins.katex) { %> + <%- theme.plugins.katex.min_css %> +<% } %> diff --git a/layout/_partial/plugins/parser/katex/script.ejs b/layout/_partial/plugins/parser/katex/script.ejs new file mode 100644 index 0000000..c51d756 --- /dev/null +++ b/layout/_partial/plugins/parser/katex/script.ejs @@ -0,0 +1,4 @@ +<% if (theme.plugins.katex) { %> + <%- theme.plugins.katex.min_js %> + <%- theme.plugins.katex.auto_render_min_js %> +<% } %> diff --git a/layout/_partial/plugins/parser/script.ejs b/layout/_partial/plugins/parser/script.ejs index f1e95b2..b30bf39 100644 --- a/layout/_partial/plugins/parser/script.ejs +++ b/layout/_partial/plugins/parser/script.ejs @@ -1,3 +1,6 @@ +<% if (page.katex == true) { %> + <%- partial('katex/script') %> +<% } %> <% if (page.mathjax == true) { %> <%- partial('mathjax/script') %> <% } %> diff --git a/layout/_partial/scripts/index.ejs b/layout/_partial/scripts/index.ejs index ce494e7..a57f201 100644 --- a/layout/_partial/scripts/index.ejs +++ b/layout/_partial/scripts/index.ejs @@ -1,3 +1,20 @@ +<% + +function custom_inject() { + var el = ''; + for (let item of (config.inject?.script || [])) { + el += item; + } + for (let item of (theme.inject?.script || [])) { + el += item; + } + for (let item of (page.inject?.script || [])) { + el += item; + } + return el; +} + +%>