🐛 Fix: add Mermaid support in home scope

This commit is contained in:
Cell
2025-08-20 11:37:10 +08:00
parent d4305d9bb2
commit 841eb3d20f
5 changed files with 14 additions and 19 deletions
+6 -7
View File
@@ -78,8 +78,12 @@ async function loadMermaid({ theme, darkMode, selector }) {
}
async function initMermaid() {
const contentEl = document.getElementById('content');
if (!contentEl || !contentEl.innerHTML) return
const mermaidElements = document.querySelectorAll('.mermaid, .mermaid-dark, .mermaid-neutral')
if (!mermaidElements.length) return
console.log(
`%c💫 FixIt Mermaid`,
'color: #FF3670; font-weight: bold; font-size: 16px; text-shadow: 1px 1px 2px rgba(0,0,0,0.1);',
)
const currentTheme = getTheme()
const nextTheme = getTheme(true)
const darkMode = document.documentElement.dataset.theme === 'dark'
@@ -95,11 +99,6 @@ window.FixItMermaid = {
}
window.mermaid = mermaid
console.log(
`%c💫 FixIt Mermaid`,
'color: #FF3670; font-weight: bold; font-size: 16px; text-shadow: 1px 1px 2px rgba(0,0,0,0.1);',
)
if (document.readyState !== 'loading') {
initMermaid()
} else {
@@ -1,2 +1,5 @@
{{- dict "Options" .Attributes "Inner" .Inner | partial "plugin/mermaid.html" -}}
{{- .Page.Store.Set "hasMermaid" true -}}
{{- if eq hugo.Context.MarkupScope "home" -}}
{{- site.Home.Store.Set "hasMermaid" true -}}
{{- end -}}
+1 -1
View File
@@ -1,4 +1,4 @@
{{- hugo.Store.Set "version" "v0.4.0-alpha-20250820030120-93acf8ea" -}}
{{- hugo.Store.Set "version" "v0.4.0-alpha-20250820033711-d4305d9b" -}}
{{- .Store.Set "this" dict -}}
{{- partial "init/detection-env.html" . -}}
+1 -11
View File
@@ -17,8 +17,6 @@ The FixIt theme supports two ways to use Mermaid: code block syntax and shortcod
## Flowchart
### Code Block Syntax
```mermaid
flowchart TD
A[Start] --> B{Is it?}
@@ -28,15 +26,7 @@ flowchart TD
B ---->|No| E[End]
```
### Shortcode Syntax
{{< mermaid >}}
flowchart LR
A[Hard edge] -->|Link text| B(Round edge)
B --> C{Decision}
C -->|One| D[Result one]
C -->|Two| E[Result two]
{{< /mermaid >}}
<!--more-->
## Sequence Diagram
+3
View File
@@ -47,3 +47,6 @@ baseURL = "https://demo.fixit.lruihao.cn/test/"
[params.mermaid]
zenuml = "https://cdn.jsdelivr.net/npm/@mermaid-js/mermaid-zenuml/dist/mermaid-zenuml.esm.min.mjs"
[params.home.posts]
paginate = 1