File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,6 +50,8 @@ const cleanSlug = (p: string) =>
5050const toPosix = ( s : string ) => {
5151 return posix . normalize ( s . replace ( / \\ / g, "/" ) )
5252}
53+ const stripExt = ( s : string ) => s . replace ( / \. ( m d | m d x ) $ / i, "" )
54+ const stripTrailingIndex = ( s : string ) => s . replace ( / \/ i n d e x $ / i, "" )
5355
5456/*
5557 * This collection defines a documentation section shown in the sidebar of the package documentation.
@@ -63,7 +65,7 @@ const section = defineCollection({
6365 include : "**/index.md" ,
6466 schema : sectionSchema ,
6567 transform : ( document ) => {
66- const slug = cleanSlug ( document . _meta . path )
68+ const slug = stripTrailingIndex ( cleanSlug ( document . _meta . path ) )
6769 return { ...document , slug }
6870 } ,
6971} )
@@ -79,7 +81,8 @@ const page = defineCollection({
7981 include : "**/**/*.mdx" ,
8082 schema : pageSchema ,
8183 transform : async ( document , context ) => {
82- const slug = cleanSlug ( document . _meta . path )
84+ const cleanedSlug = cleanSlug ( document . _meta . path )
85+ const slug = stripExt ( cleanedSlug )
8386 const content = await compileMDX ( context , document , { rehypePlugins : [ rehypeSlug ] } )
8487 const rawMdx = document . content . replace ( / ^ - - - \s * [ \r \n ] ( .* ?| \r | \n ) - - - / , "" ) . trim ( )
8588
You can’t perform that action at this time.
0 commit comments