fix: misc
This commit is contained in:
@@ -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 类型映射
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user