File tree Expand file tree Collapse file tree 2 files changed +2
-21
lines changed
Expand file tree Collapse file tree 2 files changed +2
-21
lines changed Original file line number Diff line number Diff line change @@ -62,24 +62,6 @@ export function pathFromFilename(filename: string): string {
6262 . toLowerCase ( ) ;
6363}
6464
65- function parseFrontMatter ( content : string ) {
66- if ( typeof content !== 'string' ) return { data : { } , content : '' } ;
67- const frontMatterMatch = content . match ( / ^ - - - \n ( [ \s \S ] * ?) \n - - - / ) ;
68- if ( ! frontMatterMatch ) return { data : { } , content } ;
69-
70- const frontMatter = frontMatterMatch [ 1 ] ;
71- const data : Record < string , any > = { } ;
72-
73- frontMatter . split ( '\n' ) . forEach ( line => {
74- const [ key , ...valueParts ] = line . split ( ':' ) ;
75- if ( key && valueParts . length ) {
76- const value = valueParts . join ( ':' ) . trim ( ) ;
77- data [ key . trim ( ) ] = value . replace ( / ^ [ " ' ] | [ " ' ] $ / g, '' ) ; // Remove quotes if present
78- }
79- } ) ;
80-
81- return { data, content : content . slice ( frontMatterMatch [ 0 ] . length ) } ;
82- }
8365
8466export let completeFrontMatter : Record < string , any > [ ] = [ ] ;
8567export function isFrontmatterReady ( ) { return preloadedFrontMatter !== null ; }
Original file line number Diff line number Diff line change @@ -36,9 +36,8 @@ export default function Layout({ children }: LayoutProps) {
3636 } , [ pathname ] ) ;
3737
3838 const handleCopyMDX = useCallback ( ( ) => {
39- ALL_PAGES [ pathFromFilename ( pathname ) ] ( ) . then ( ( mdx ) => {
40- navigator . clipboard . writeText ( mdx . default . toString ( ) ) ;
41- } ) ;
39+ const mod = ALL_PAGES [ pathFromFilename ( pathname ) ] ;
40+ if ( mod ) navigator . clipboard . writeText ( ( mod as any ) . default . toString ( ) ) ;
4241 showNotification ( 'Copied to clipboard' ) ;
4342 } , [ ] ) ;
4443 const handleOpenChatGPT = useCallback ( ( ) => {
You can’t perform that action at this time.
0 commit comments