diff --git a/content/sparks.csv b/content/sparks.csv index be34f25..900248f 100644 --- a/content/sparks.csv +++ b/content/sparks.csv @@ -1,6 +1,6 @@ -label,body,adj,noun,group -🔥,**{{adj}}** 的{{noun}},高大,战士,基本 -💧,{{adj}}的{{noun}},矮小,法师,基本 -🌪️,{{adj}}的{{noun}},帅气,弓手,高级 -🌱,{{adj}}的{{noun}},丑陋,盗贼,高级 -⚡,{{adj}}的{{noun}},平庸,牧师,高级 +label,body,adj,noun +1,**{{adj}}** 的{{noun}},高大,战士 +2,{{adj}}的{{noun}},矮小,法师 +3,{{adj}}的{{noun}},帅气,弓手 +4,{{adj}}的{{noun}},丑陋,盗贼 +5,{{adj}}的{{noun}},平庸,牧师 diff --git a/src/cli/commands/serve.ts b/src/cli/commands/serve.ts index edeb4fd..c7cb380 100644 --- a/src/cli/commands/serve.ts +++ b/src/cli/commands/serve.ts @@ -15,7 +15,7 @@ interface ContentIndex { */ const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); -const distDir = resolve(__dirname, "..", "..", "web"); +const distDir = resolve(__dirname, "..", "..", "..", "dist", "web"); /** * MIME 类型映射 diff --git a/src/components/FileTree.tsx b/src/components/FileTree.tsx index a46fa9b..2be08ec 100644 --- a/src/components/FileTree.tsx +++ b/src/components/FileTree.tsx @@ -2,6 +2,15 @@ import { Component, createMemo, createSignal, Show } from "solid-js"; import { type FileNode, type TocNode } from "../data-loader"; import { useNavigate } from "@solidjs/router"; +/** + * 检查当前文件路径是否在文件夹内 + */ +function isPathInDir(currentPath: string, dirPath: string): boolean { + // 确保 dirPath 以 / 结尾,用于前缀匹配 + const dirPathPrefix = dirPath.endsWith('/') ? dirPath : dirPath + '/'; + return currentPath.startsWith(dirPathPrefix); +} + /** * 文件树节点组件 */ @@ -13,9 +22,10 @@ export const FileTreeNode: Component<{ onClose: () => void; }> = (props) => { const navigate = useNavigate(); - const [isExpanded, setIsExpanded] = createSignal(true); const isDir = !!props.node.children; const isActive = createMemo(() => props.currentPath === props.node.path); + // 默认收起,除非当前文件在该文件夹内 + const [isExpanded, setIsExpanded] = createSignal(isDir && isPathInDir(props.currentPath, props.node.path)); const handleClick = () => { if (isDir) { diff --git a/src/markdown/index.ts b/src/markdown/index.ts index 3b69d02..a6c08df 100644 --- a/src/markdown/index.ts +++ b/src/markdown/index.ts @@ -5,7 +5,7 @@ import { createDirectives } from 'marked-directive'; const marked = new Marked().use(createDirectives()); export function parseMarkdown(content: string): string { - return marked.parse(content) as string; + return marked.parse(content.trimStart()) as string; } export { marked };