diff --git a/src/components/Toc.astro b/src/components/Toc.astro index d2b8249..61347c7 100644 --- a/src/components/Toc.astro +++ b/src/components/Toc.astro @@ -17,12 +17,11 @@ .map((page) => { const fileName = page.file.split("/").pop()?.replace(".mdx", "") || ""; const url = `/${sectionPath}/${fileName}`; - const title = - (page as any).title || - page.frontmatter?.title || - fileName.replace(/^\d+-/, "").replace(/-/g, " "); - return { url, title, order: parseInt(fileName) || 999 }; + const [index, titlePart] = fileName.split("-"); + const title = (page as any).title || page.frontmatter?.title || titlePart; + + return { url, title, order: index }; }) .sort((a, b) => a.order - b.order); }