feat: mermaid
This commit is contained in:
@@ -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();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user