fix: misc
This commit is contained in:
parent
04dfa77eaf
commit
e57e09ae05
|
|
@ -1,6 +1,6 @@
|
||||||
label,body,adj,noun,group
|
label,body,adj,noun
|
||||||
🔥,**{{adj}}** 的{{noun}},高大,战士,基本
|
1,**{{adj}}** 的{{noun}},高大,战士
|
||||||
💧,{{adj}}的{{noun}},矮小,法师,基本
|
2,{{adj}}的{{noun}},矮小,法师
|
||||||
🌪️,{{adj}}的{{noun}},帅气,弓手,高级
|
3,{{adj}}的{{noun}},帅气,弓手
|
||||||
🌱,{{adj}}的{{noun}},丑陋,盗贼,高级
|
4,{{adj}}的{{noun}},丑陋,盗贼
|
||||||
⚡,{{adj}}的{{noun}},平庸,牧师,高级
|
5,{{adj}}的{{noun}},平庸,牧师
|
||||||
|
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ interface ContentIndex {
|
||||||
*/
|
*/
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
const __dirname = dirname(__filename);
|
const __dirname = dirname(__filename);
|
||||||
const distDir = resolve(__dirname, "..", "..", "web");
|
const distDir = resolve(__dirname, "..", "..", "..", "dist", "web");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MIME 类型映射
|
* MIME 类型映射
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,15 @@ import { Component, createMemo, createSignal, Show } from "solid-js";
|
||||||
import { type FileNode, type TocNode } from "../data-loader";
|
import { type FileNode, type TocNode } from "../data-loader";
|
||||||
import { useNavigate } from "@solidjs/router";
|
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;
|
onClose: () => void;
|
||||||
}> = (props) => {
|
}> = (props) => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [isExpanded, setIsExpanded] = createSignal(true);
|
|
||||||
const isDir = !!props.node.children;
|
const isDir = !!props.node.children;
|
||||||
const isActive = createMemo(() => props.currentPath === props.node.path);
|
const isActive = createMemo(() => props.currentPath === props.node.path);
|
||||||
|
// 默认收起,除非当前文件在该文件夹内
|
||||||
|
const [isExpanded, setIsExpanded] = createSignal(isDir && isPathInDir(props.currentPath, props.node.path));
|
||||||
|
|
||||||
const handleClick = () => {
|
const handleClick = () => {
|
||||||
if (isDir) {
|
if (isDir) {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import { createDirectives } from 'marked-directive';
|
||||||
const marked = new Marked().use(createDirectives());
|
const marked = new Marked().use(createDirectives());
|
||||||
|
|
||||||
export function parseMarkdown(content: string): string {
|
export function parseMarkdown(content: string): string {
|
||||||
return marked.parse(content) as string;
|
return marked.parse(content.trimStart()) as string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export { marked };
|
export { marked };
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue