Skip to content

Commit

Permalink
fix: getScripts load
Browse files Browse the repository at this point in the history
  • Loading branch information
YunYouJun committed May 4, 2022
1 parent 8b1658c commit 6d39d3b
Show file tree
Hide file tree
Showing 7 changed files with 5,017 additions and 155 deletions.
1 change: 1 addition & 0 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
},
"devDependencies": {
"hexo": "6.1.0",
"hexo-browsersync": "^0.3.0",
"hexo-generator-archive": "^1.0.0",
"hexo-generator-category": "^1.0.0",
"hexo-generator-feed": "^3.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#minivaline-container
- var minivalineConfig = JSON.stringify(theme.minivaline)
script.
Yun.utils.getScript("#{theme.vendors.minivaline_js}", () => {
script(type="module").
import { getScript } from '/js/utils.js'
getScript("#{theme.vendors.minivaline_js}", () => {
const minivalineConfig = !{minivalineConfig}
minivalineConfig.el = "#minivaline-container"
new MiniValine(minivalineConfig);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
//- after init, #tcomment will be #twikoo
#tcomment
- var twikooConfig = JSON.stringify(theme.twikoo)
script.
Yun.utils.getScript("#{theme.vendors.twikoo}", () => {
script(type="module").
import { getScript } from '/js/utils.js'

getScript("#{theme.vendors.twikoo}", () => {
const twikooConfig = !{twikooConfig}
twikooConfig.el = '#tcomment'
twikoo.init(twikooConfig)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
//- not use valine_config() for window.location.pathname
- theme.valine.el = "#valine-container"
- theme.valine.lang = (theme.valine.lang || config.language || "zh-cn").toLowerCase()
script.
Yun.utils.getScript("#{theme.vendors.valine_js}", () => {
script(type="module").
import { getScript } from '/js/utils.js'
getScript("#{theme.vendors.valine_js}", () => {
const valineConfig = !{JSON.stringify(theme.valine)}
valineConfig.path = "#{url_for(page.path)}"
new Valine(valineConfig)
Expand Down
5 changes: 3 additions & 2 deletions packages/hexo-theme-yun/layout/_third-party/math/katex.pug
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ if theme.katex.copy_tex
script(defer, src=theme.vendors.katex.copy_tex.js)

script(defer src=theme.vendors.katex.auto_render)
script.
script(type="module").
import { renderKatex } from '/js/utils.js'
document.addEventListener("DOMContentLoaded", () => {
Yun.utils.renderKatex({
renderKatex({
...!{JSON.stringify(theme.katex.options)},
...!{String(JSON.stringify(page.katex))}?.options,
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
script.
Yun.utils.getScript("#{theme.vendors.mermaid}", () => {
script(type="module").
import { getScript } from '/js/utils.js'
getScript("#{theme.vendors.mermaid}", () => {
const mermaidOptions = !{JSON.stringify(theme.mermaid.options)}
mermaid.initialize(mermaidOptions);
}, window.mermaid);
Expand Down
Loading

1 comment on commit 6d39d3b

@vercel
Copy link

@vercel vercel bot commented on 6d39d3b May 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.