Skip to content

Commit 1d14df6

Browse files
authored
Merge pull request #18 from mambax7/master
Mermaid fixes
2 parents 4857a2c + 018324f commit 1d14df6

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

apps/docs-27/public/mermaid-init.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,14 @@ async function rerenderMermaid() {
7272
}
7373
}
7474

75-
// astro:page-load fires on every navigation AND on the initial page load
75+
// Static Starlight pages do not emit astro:page-load unless Astro's client
76+
// router is present, so render once on normal page load as well.
77+
if (document.readyState === 'loading') {
78+
document.addEventListener('DOMContentLoaded', renderMermaid, { once: true });
79+
} else {
80+
renderMermaid();
81+
}
82+
7683
document.addEventListener('astro:page-load', renderMermaid);
7784

7885
// Re-render with correct palette when the user toggles dark/light

apps/docs-4x/public/mermaid-init.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,14 @@ async function rerenderMermaid() {
7272
}
7373
}
7474

75-
// astro:page-load fires on every navigation AND on the initial page load
75+
// Static Starlight pages do not emit astro:page-load unless Astro's client
76+
// router is present, so render once on normal page load as well.
77+
if (document.readyState === 'loading') {
78+
document.addEventListener('DOMContentLoaded', renderMermaid, { once: true });
79+
} else {
80+
renderMermaid();
81+
}
82+
7683
document.addEventListener('astro:page-load', renderMermaid);
7784

7885
// Re-render with correct palette when the user toggles dark/light

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
"dev:4x": "pnpm --filter docs-4x dev",
77
"build:27": "pnpm --filter docs-27 build",
88
"build:4x": "pnpm --filter docs-4x build",
9-
"build:all": "pnpm --filter 'docs-*' build"
9+
"build:all": "pnpm --filter \"docs-*\" build"
1010
}
11-
}
11+
}

0 commit comments

Comments
 (0)