feat: mermaid

This commit is contained in:
2026-03-02 11:03:51 +08:00
parent e8ce7b7216
commit b737e9f4ea
6 changed files with 1297 additions and 35 deletions
+3
View File
@@ -1,6 +1,7 @@
import { Component, createSignal, createEffect, onCleanup, Show, createResource } from 'solid-js';
import { parseMarkdown } from '../markdown';
import { fetchData, extractSection } from '../data-loader';
import mermaid from 'mermaid';
export interface ArticleProps {
src: string;
@@ -30,6 +31,8 @@ export const Article: Component<ArticleProps> = (props) => {
const data = content();
if (data) {
props.onLoaded?.();
// 内容加载完成后,渲染 mermaid 图表
void mermaid.run();
}
});
+7
View File
@@ -87,6 +87,13 @@ export const HeadingNode: Component<{
const handleClick = (e: MouseEvent) => {
e.preventDefault();
navigate(href);
// 滚动到目标元素
requestAnimationFrame(() => {
const element = document.getElementById(anchor);
if (element) {
element.scrollIntoView({ behavior: "smooth", block: "start" });
}
});
};
const indent = props.depth * 12;