Skip to content

Commit 4aaf5a3

Browse files
author
abrulic
committed
small update with helper functions in content-collections.ts
1 parent b711bcc commit 4aaf5a3

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

content-collections.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ const cleanSlug = (p: string) =>
5050
const toPosix = (s: string) => {
5151
return posix.normalize(s.replace(/\\/g, "/"))
5252
}
53-
const stripExt = (s: string) => s.replace(/\.(md|mdx)$/i, "")
54-
const stripTrailingIndex = (s: string) => s.replace(/\/index$/i, "")
5553

5654
/*
5755
* This collection defines a documentation section shown in the sidebar of the package documentation.
@@ -65,7 +63,7 @@ const section = defineCollection({
6563
include: "**/index.md",
6664
schema: sectionSchema,
6765
transform: (document) => {
68-
const slug = stripTrailingIndex(cleanSlug(document._meta.path))
66+
const slug = cleanSlug(document._meta.path)
6967
return { ...document, slug }
7068
},
7169
})
@@ -81,8 +79,7 @@ const page = defineCollection({
8179
include: "**/**/*.mdx",
8280
schema: pageSchema,
8381
transform: async (document, context) => {
84-
const rel = cleanSlug(document._meta.path)
85-
const slug = stripExt(rel)
82+
const slug = cleanSlug(document._meta.path)
8683
const content = await compileMDX(context, document, { rehypePlugins: [rehypeSlug] })
8784
const rawMdx = document.content.replace(/^---\s*[\r\n](.*?|\r|\n)---/, "").trim()
8885

0 commit comments

Comments
 (0)