[opt] head & inject
This commit is contained in:
parent
29d031f95b
commit
5d7f131c0e
11
_config.yml
11
_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 <mathjax: true> 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 <katex: true> to enable in page's front-matter
|
||||
min_css: <link rel="stylesheet" href="https://gcore.jsdelivr.net/npm/katex@0.16.4/dist/katex.min.css" integrity="sha384-vKruj+a13U8yHIkAyGgK1J3ArTLzrFGBbBc0tDp4ad/EyewESeXE/Iv67Aj8gKZ0" crossorigin="anonymous">
|
||||
min_js: <script defer src="https://gcore.jsdelivr.net/npm/katex@0.16.4/dist/katex.min.js" integrity="sha384-PwRUT/YqbnEjkZO0zZxNqcxACrXe+j766U2amXcgMg5457rve2Y7I6ZJSm2A0mS4" crossorigin="anonymous"></script>
|
||||
auto_render_min_js: <script defer src="https://gcore.jsdelivr.net/npm/katex@0.16.4/dist/contrib/auto-render.min.js" integrity="sha384-+VBxd3r6XgURycqtZ117nYw44OOcIax56Z4dCRWbxyPt0Koah1uHoK0o4+/RRE05" crossorigin="anonymous"onload="renderMathInElement(document.body);"></script>
|
||||
|
@ -376,7 +380,8 @@ plugins:
|
|||
# B -->|option 2| C(Section C)
|
||||
# ```
|
||||
mermaid:
|
||||
enable: true
|
||||
# set <mermaid: true> 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
|
||||
|
|
|
@ -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 += `<link rel="preconnect" href="${href}" crossorigin>`;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
%>
|
||||
|
||||
<head>
|
||||
<%- meta_generator() %>
|
||||
<meta name="hexo-theme" content="<%- stellar_info('tree') %>" version="<%- stellar_info('version') %>">
|
||||
<meta charset="utf-8">
|
||||
<meta name="hexo-theme" content="<%- stellar_info('tree') %>" version="<%- stellar_info('version') %>">
|
||||
<%- generate_robots() %>
|
||||
|
||||
<%- meta_generator() %>
|
||||
<meta http-equiv='x-dns-prefetch-control' content='on' />
|
||||
<link rel='dns-prefetch' href='https://gcore.jsdelivr.net'>
|
||||
<link rel="preconnect" href="https://gcore.jsdelivr.net" crossorigin>
|
||||
<link rel='dns-prefetch' href='//unpkg.com'>
|
||||
|
||||
<%- preconnect() %>
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta name="force-rendering" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
|
||||
|
@ -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() %>
|
||||
</head>
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<% if (page.katex == true) { %>
|
||||
<%- partial('katex/head') %>
|
||||
<% } %>
|
|
@ -0,0 +1,3 @@
|
|||
<% if (theme.plugins.katex) { %>
|
||||
<%- theme.plugins.katex.min_css %>
|
||||
<% } %>
|
|
@ -0,0 +1,4 @@
|
|||
<% if (theme.plugins.katex) { %>
|
||||
<%- theme.plugins.katex.min_js %>
|
||||
<%- theme.plugins.katex.auto_render_min_js %>
|
||||
<% } %>
|
|
@ -1,3 +1,6 @@
|
|||
<% if (page.katex == true) { %>
|
||||
<%- partial('katex/script') %>
|
||||
<% } %>
|
||||
<% if (page.mathjax == true) { %>
|
||||
<%- partial('mathjax/script') %>
|
||||
<% } %>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
%>
|
||||
<script type="text/javascript">
|
||||
const stellar = {
|
||||
// 懒加载 css https://github.com/filamentgroup/loadCSS
|
||||
|
@ -160,8 +177,4 @@
|
|||
<%- partial('../plugins/parser/script') %>
|
||||
|
||||
<!-- inject -->
|
||||
<% if (config.inject && config.inject.script && config.inject.script.length > 0) { %>
|
||||
<% config.inject.script.forEach(function(js) { %>
|
||||
<%- js %>
|
||||
<% }) %>
|
||||
<% } %>
|
||||
<%- custom_inject() %>
|
||||
|
|
|
@ -79,6 +79,8 @@
|
|||
display: none
|
||||
&.active
|
||||
display: block
|
||||
.tab-content:has(.grid-box)
|
||||
width: 100%
|
||||
|
||||
.md-text.indent .tag-plugin.tabs .tab-content p:not([class])
|
||||
text-indent: 'calc(%s * 2)' % $fs-p
|
||||
|
|
|
@ -9,7 +9,7 @@ if hexo-config('plugins.scrollreveal.enable')
|
|||
@import 'scrollreveal'
|
||||
if hexo-config('plugins.fancybox.enable')
|
||||
@import 'fancybox'
|
||||
if hexo-config('plugins.mermaid.enable')
|
||||
if hexo-config('plugins.mermaid.style_optimization')
|
||||
@import 'mermaid'
|
||||
if hexo-config('plugins.copycode.enable')
|
||||
@import 'copycode'
|
||||
|
|
Loading…
Reference in New Issue