@@ -10,6 +10,7 @@ import rehypeHighlight from 'rehype-highlight';
1010import rehypeSlug from 'rehype-slug' ;
1111import GithubSlugger from 'github-slugger' ;
1212import 'highlight.js/styles/github-dark.css' ;
13+ import { parseFrontmatter } from '../lib/markdown' ;
1314
1415type DownloadFile = {
1516 path : string ;
@@ -56,6 +57,36 @@ function extractHeadings(markdown: string): Heading[] {
5657 return headings ;
5758}
5859
60+ function ExperienceMarkdown ( { content } : { content : string } ) {
61+ const { meta, body } = parseFrontmatter ( content ) ;
62+ return (
63+ < div className = "space-y-4" >
64+ { meta && (
65+ < div className = "rounded-lg border bg-muted/30 px-4 py-3" >
66+ < dl className = "grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 text-sm" >
67+ { Object . entries ( meta ) . map ( ( [ key , val ] ) => (
68+ < React . Fragment key = { key } >
69+ < dt className = "text-muted-foreground font-medium" > { key } </ dt >
70+ < dd className = "text-foreground break-words" > { val } </ dd >
71+ </ React . Fragment >
72+ ) ) }
73+ </ dl >
74+ </ div >
75+ ) }
76+ { body . trim ( ) && (
77+ < div className = "prose dark:prose-invert max-w-none prose-headings:font-semibold prose-headings:scroll-mt-20 prose-a:text-primary prose-a:no-underline hover:prose-a:underline prose-img:rounded-lg prose-code:before:content-none prose-code:after:content-none" >
78+ < ReactMarkdown
79+ remarkPlugins = { [ remarkGfm ] }
80+ rehypePlugins = { [ rehypeHighlight , rehypeSlug ] }
81+ >
82+ { body }
83+ </ ReactMarkdown >
84+ </ div >
85+ ) }
86+ </ div >
87+ ) ;
88+ }
89+
5990// In a real app, this data would come from the astro page props (fetched from getCollection)
6091export function ExperienceDetailApp ( { experienceId, experienceData, lang = 'zh' } : { experienceId : string , experienceData : ExperienceDetailData , lang ?: 'zh' | 'en' } ) {
6192 const [ currentLang , setCurrentLang ] = useState ( lang ) ;
@@ -207,16 +238,9 @@ export function ExperienceDetailApp({ experienceId, experienceData, lang = 'zh'
207238 < div className = "flex-1 w-full order-2 lg:order-1 min-w-0" >
208239 < div className = "bg-card rounded-xl border shadow-sm p-6 md:p-10" >
209240 { ( activeFile . endsWith ( '.md' ) || activeFile . endsWith ( '.mdx' ) ) ? (
210- < div className = "prose prose-slate dark:prose-invert max-w-none prose-headings:font-semibold prose-headings:scroll-mt-20 prose-a:text-primary prose-a:no-underline hover:prose-a:underline prose-img:rounded-lg" >
211- < ReactMarkdown
212- remarkPlugins = { [ remarkGfm ] }
213- rehypePlugins = { [ rehypeHighlight , rehypeSlug ] }
214- >
215- { currentFileContent }
216- </ ReactMarkdown >
217- </ div >
241+ < ExperienceMarkdown content = { currentFileContent } />
218242 ) : (
219- < pre className = "overflow-x-auto p-4 bg-muted/50 rounded-lg text-sm font-mono whitespace-pre-wrap" >
243+ < pre className = "overflow-x-auto p-4 bg-muted/50 rounded-lg text-[0.875rem] leading-relaxed font-mono whitespace-pre-wrap" >
220244 < code > { currentFileContent } </ code >
221245 </ pre >
222246 ) }
0 commit comments