Skip to content

Commit

Permalink
Fix mermaid in static build, change article title
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengrice committed May 4, 2024
1 parent 192dbac commit 98ea4f9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/content/post/blog/2024/plaintext-architecture.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "A Software Architecture for Plaintext and Self-Hosting (on All Platforms)"
title: "Software Architecture for Plaintext and Self-Hosting"
publishDate: 2024-04-12
# image: http://i3.ytimg.com/vi/Bn1Okg6Z4ac/hqdefault.jpg
author: Steve Grice
Expand Down
7 changes: 4 additions & 3 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@ const { language, textDirection } = I18N;
content-visibility: auto;
}
</style>
<script>
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';

// Source: https://github.com/JuanM04/portfolio/blob/983b0ed0eabdac37bf8b7912d3e8128a443192b9/src/pages/docs/%5B...documentSlug%5D.astro#L74-L103
// From this comment: https://github.com/withastro/astro/issues/4433#issuecomment-1584019991
/**
* @params {HTMLCollectionOf<HTMLElement>} graphs
*/
async function renderDiagrams(graphs) {
const {default: mermaid} = await import("mermaid")
// const {default: mermaid} = await import("mermaid")
mermaid.initialize({
startOnLoad: false,
fontFamily: "var(--sans-font)",
Expand All @@ -77,7 +79,6 @@ const { language, textDirection } = I18N;
})
}
}

const graphs = document.getElementsByClassName("mermaid")
if (document.getElementsByClassName("mermaid").length > 0) {
renderDiagrams(graphs);
Expand Down

0 comments on commit 98ea4f9

Please sign in to comment.