fix: mermaid script load order
This commit is contained in:
parent
a8001e9554
commit
9e3e711646
4 changed files with 34 additions and 29 deletions
|
@ -31,13 +31,13 @@ If you prefer instructions in a video format you can try following Nicole van de
|
||||||
|
|
||||||
## 🔧 Features
|
## 🔧 Features
|
||||||
|
|
||||||
- [[Obsidian compatibility]], [[full-text search]], [[graph view]], note transclusion, [[wikilinks]], [[backlinks]], [[features/Latex|Latex]], [[syntax highlighting]], [[popover previews]], [[Docker Support]], [[i18n|internationalization]], [[comments]] and [many more](./features) right out of the box
|
- [[Obsidian compatibility]], [[full-text search]], [[graph view]], note transclusion, [[wikilinks]], [[backlinks]], [[features/Latex|Latex]], [[syntax highlighting]], [[popover previews]], [[Docker Support]], [[i18n|internationalization]], [[comments]] and [many more](./features/) right out of the box
|
||||||
- Hot-reload for both configuration and content
|
- Hot-reload for both configuration and content
|
||||||
- Simple JSX layouts and [[creating components|page components]]
|
- Simple JSX layouts and [[creating components|page components]]
|
||||||
- [[SPA Routing|Ridiculously fast page loads]] and tiny bundle sizes
|
- [[SPA Routing|Ridiculously fast page loads]] and tiny bundle sizes
|
||||||
- Fully-customizable parsing, filtering, and page generation through [[making plugins|plugins]]
|
- Fully-customizable parsing, filtering, and page generation through [[making plugins|plugins]]
|
||||||
|
|
||||||
For a comprehensive list of features, visit the [features page](/features). You can read more about the _why_ behind these features on the [[philosophy]] page and a technical overview on the [[architecture]] page.
|
For a comprehensive list of features, visit the [features page](./features/). You can read more about the _why_ behind these features on the [[philosophy]] page and a technical overview on the [[architecture]] page.
|
||||||
|
|
||||||
### 🚧 Troubleshooting + Updating
|
### 🚧 Troubleshooting + Updating
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,14 @@ export function pageResources(
|
||||||
additionalHead: staticResources.additionalHead,
|
additionalHead: staticResources.additionalHead,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resources.js.push({
|
||||||
|
src: joinSegments(baseDir, "postscript.js"),
|
||||||
|
loadTime: "afterDOMReady",
|
||||||
|
moduleType: "module",
|
||||||
|
contentType: "external",
|
||||||
|
})
|
||||||
|
|
||||||
|
// dynamic afterDOMReady must come after postscript.js
|
||||||
if (fileData.hasMermaidDiagram) {
|
if (fileData.hasMermaidDiagram) {
|
||||||
resources.js.push({
|
resources.js.push({
|
||||||
script: mermaidScript,
|
script: mermaidScript,
|
||||||
|
@ -68,14 +76,6 @@ export function pageResources(
|
||||||
resources.css.push({ content: mermaidStyle, inline: true })
|
resources.css.push({ content: mermaidStyle, inline: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: we have to put this last to make sure spa.inline.ts is the last item.
|
|
||||||
resources.js.push({
|
|
||||||
src: joinSegments(baseDir, "postscript.js"),
|
|
||||||
loadTime: "afterDOMReady",
|
|
||||||
moduleType: "module",
|
|
||||||
contentType: "external",
|
|
||||||
})
|
|
||||||
|
|
||||||
return resources
|
return resources
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,8 @@ function setupCallout() {
|
||||||
) as HTMLCollectionOf<HTMLElement>
|
) as HTMLCollectionOf<HTMLElement>
|
||||||
for (const div of collapsible) {
|
for (const div of collapsible) {
|
||||||
const title = div.firstElementChild
|
const title = div.firstElementChild
|
||||||
|
if (!title) continue
|
||||||
|
|
||||||
if (title) {
|
|
||||||
title.addEventListener("click", toggleCallout)
|
title.addEventListener("click", toggleCallout)
|
||||||
window.addCleanup(() => title.removeEventListener("click", toggleCallout))
|
window.addCleanup(() => title.removeEventListener("click", toggleCallout))
|
||||||
|
|
||||||
|
@ -38,7 +38,5 @@ function setupCallout() {
|
||||||
div.style.maxHeight = height + "px"
|
div.style.maxHeight = height + "px"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener("nav", setupCallout)
|
document.addEventListener("nav", setupCallout)
|
||||||
window.addEventListener("resize", setupCallout)
|
|
||||||
|
|
|
@ -56,8 +56,10 @@ function startLoading() {
|
||||||
}, 100)
|
}, 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let isNavigating = false
|
||||||
let p: DOMParser
|
let p: DOMParser
|
||||||
async function navigate(url: URL, isBack: boolean = false) {
|
async function _navigate(url: URL, isBack: boolean = false) {
|
||||||
|
isNavigating = true
|
||||||
startLoading()
|
startLoading()
|
||||||
p = p || new DOMParser()
|
p = p || new DOMParser()
|
||||||
const contents = await fetchCanonical(url)
|
const contents = await fetchCanonical(url)
|
||||||
|
@ -128,6 +130,19 @@ async function navigate(url: URL, isBack: boolean = false) {
|
||||||
delete announcer.dataset.persist
|
delete announcer.dataset.persist
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function navigate(url: URL, isBack: boolean = false) {
|
||||||
|
if (isNavigating) return
|
||||||
|
isNavigating = true
|
||||||
|
try {
|
||||||
|
await _navigate(url, isBack)
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
|
window.location.assign(url)
|
||||||
|
} finally {
|
||||||
|
isNavigating = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
window.spaNavigate = navigate
|
window.spaNavigate = navigate
|
||||||
|
|
||||||
function createRouter() {
|
function createRouter() {
|
||||||
|
@ -145,21 +160,13 @@ function createRouter() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
navigate(url, false)
|
navigate(url, false)
|
||||||
} catch (e) {
|
|
||||||
window.location.assign(url)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
window.addEventListener("popstate", (event) => {
|
window.addEventListener("popstate", (event) => {
|
||||||
const { url } = getOpts(event) ?? {}
|
const { url } = getOpts(event) ?? {}
|
||||||
if (window.location.hash && window.location.pathname === url?.pathname) return
|
if (window.location.hash && window.location.pathname === url?.pathname) return
|
||||||
try {
|
|
||||||
navigate(new URL(window.location.toString()), true)
|
navigate(new URL(window.location.toString()), true)
|
||||||
} catch (e) {
|
|
||||||
window.location.reload()
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue