Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Docs0 Changelog

## 1.1.9 (2025-12-02)

- Add Mermaid diagrams support

## 1.1.8 (2025-10-24)

- Improve search indexing robustness
Expand Down
1 change: 1 addition & 0 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<script src="/assets/scripts/prism.js"></script>
<script src="/assets/scripts/medium-zoom.min.js"></script>
<script src="/assets/scripts/split.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.min.js"></script>
<script src="/assets/scripts/main.min.js"></script>
<script src="/assets/scripts/my.js"></script>
</body>
Expand Down
85 changes: 84 additions & 1 deletion assets/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ class Theme {

theme;
ctrl;
onChangeCallbacks = [];

get current() {
if (this.theme == "system") {
Expand Down Expand Up @@ -245,6 +246,10 @@ class Theme {
return isDark ? "dark" : "light";
}

onChange(callback) {
this.onChangeCallbacks.push(callback);
}

change(theme) {
localStorage.setItem("theme", theme);
this.apply(theme);
Expand All @@ -266,6 +271,84 @@ class Theme {

this.ctrl.classList.remove("icon-theme-dark", "icon-theme-light", "icon-theme-system");
this.ctrl.classList.add("icon-theme-" + this.theme);

this.onChangeCallbacks.forEach(callback => {
try {
callback(this.current);
} catch (_) {}
});
}
}
new Theme();
const theme = new Theme();

// Mermaid manager
class MermaidManager {

constructor(theme) {
this.theme = theme;

document.addEventListener("DOMContentLoaded", () => {
this.renderAll({ firstRun: true });
this.theme.onChange(() => {
this.renderAll({ firstRun: false });
});
});
}

initMermaid() {
mermaid.initialize({
startOnLoad: false,
theme: this.theme.isDark ? "dark" : "default",
securityLevel: "loose"
});
}

initialTransform() {
const blocks = document.querySelectorAll(
"pre code.language-mermaid, pre.language-mermaid code"
);

blocks.forEach(block => {
const pre = block.closest("pre");
if (!pre) return;

const code = block.textContent;
const div = document.createElement("div");
div.className = "mermaid";
div.textContent = code;
div.setAttribute("data-original-code", code);
pre.replaceWith(div);
});
}

resetDiagrams() {
document.querySelectorAll(".mermaid").forEach(diagram => {
const original = diagram.getAttribute("data-original-code");
if (!original) return;
diagram.removeAttribute("data-processed");
diagram.textContent = original;
});
}

runMermaid() {
if (typeof mermaid.run === "function") {
mermaid.run();
} else if (typeof mermaid.init === "function") {
mermaid.init(undefined, ".mermaid");
}
}

renderAll({ firstRun } = { firstRun: false }) {
if (firstRun) {
this.initialTransform();
} else {
this.resetDiagrams();
}

this.initMermaid();
this.runMermaid();
}
}

if (typeof mermaid !== "undefined")
new MermaidManager(theme);
2 changes: 1 addition & 1 deletion assets/scripts/main.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Docs0",
"version": "1.1.8",
"lastUpdated": "2025-10-24",
"version": "1.1.9",
"lastUpdated": "2025-12-02",
"scripts": {
"run (incremental)": "bundle exec jekyll serve --incremental --port 4001",
"run (full)": "bundle exec jekyll serve --port 4001",
Expand Down