File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 11---
22import { z } from " astro:schema" ;
33import { marked } from " marked" ;
4- import { slug } from " github-slugger" ;
4+ import { slug as GithubSlug } from " github-slugger" ;
55
66type Props = z .infer <typeof props >;
77
88const props = z .object ({
99 title: z .string (),
10+ slug: z .string ().optional (),
1011 depth: z .number ().min (1 ).max (6 ),
1112});
1213
13- const { title, depth } = props .parse (Astro .props );
14+ const { title, slug, depth } = props .parse (Astro .props );
15+
16+ const slugified = GithubSlug (slug ?? title );
1417
1518const Heading = ` h${depth } ` as " h1" | " h2" | " h3" | " h4" | " h5" | " h6" ;
1619---
1720
1821<div tabindex =" -1" class =`heading-wrapper level-h${depth }` >
19- <Heading id ={ slug ( title ) } set:html ={ marked .parseInline (title ) as string } />
20- <a class =" anchor-link" href ={ ` #${slug ( title ) } ` } >
22+ <Heading id ={ slugified } set:html ={ marked .parseInline (title ) as string } />
23+ <a class =" anchor-link" href ={ ` #${slugified } ` } >
2124 <span aria-hidden class =" anchor-icon" >
2225 <svg width =" 16" height =" 16" viewBox =" 0 0 24 24" >
2326 <path
You can’t perform that action at this time.
0 commit comments