@@ -13,9 +13,18 @@ interface Props {
1313 entries: AnyEntry [];
1414 emptyText: string ;
1515 hrefPrefix: " /blog/" | " /news/" | " /projects/" ;
16+ showIntroTags? : boolean ;
1617}
1718
18- const { title, description, eyebrow, entries, emptyText, hrefPrefix } =
19+ const {
20+ title,
21+ description,
22+ eyebrow,
23+ entries,
24+ emptyText,
25+ hrefPrefix,
26+ showIntroTags = true ,
27+ } =
1928 Astro .props ;
2029
2130const storageKeyMap: Record <string , string > = {
@@ -31,16 +40,36 @@ const items = entries.map((entry) => ({
3140 title: entry .data .title ,
3241 description: entry .data .description ,
3342 dateText: entry .data .date .toLocaleDateString (" zh-CN" ),
43+ dateValue: entry .data .date .toISOString (),
3444 meta: entry .data .author ,
45+ author: entry .data .author ,
46+ tags: entry .data .tags ,
3547}));
48+
49+ const introTags = [... new Set (entries .flatMap ((entry ) => entry .data .tags ))]
50+ .sort ((a , b ) => a .localeCompare (b , " zh-CN" ))
51+ .map ((tag ) => ({
52+ label: tag ,
53+ href: hrefPrefix === " /blog/" ? ` /blog/tags/${encodeURIComponent (tag )}/ ` : undefined ,
54+ }));
3655---
3756
3857<section class =" section-shell" >
3958 <div class =" container-shell" >
40- <PageIntro title ={ title } description ={ description } eyebrow ={ eyebrow } />
59+ <PageIntro
60+ title ={ title }
61+ description ={ description }
62+ eyebrow ={ eyebrow }
63+ tags ={ showIntroTags ? introTags : []}
64+ />
4165 {
4266 entries .length > 0 ? (
43- <ContentLayoutGrid client :load items = { items } storageKey = { storageKey } />
67+ <ContentLayoutGrid
68+ client :load
69+ items = { items }
70+ storageKey = { storageKey }
71+ emptyText = { emptyText }
72+ />
4473 ) : (
4574 <SurfaceCard class = " p-4 text-ink-500" >{ emptyText } </SurfaceCard >
4675 )
0 commit comments