@@ -4,9 +4,12 @@ import {
44 stripLeadingAndTrailingSlashes ,
55 ensureTrailingSlash ,
66} from ' node_modules/@astrojs/starlight/utils/path' ;
7- import { LinkCard , CardGrid } from ' @astrojs/starlight/components' ;
7+ import { CardGrid } from ' @astrojs/starlight/components' ;
88import { routes , type Route } from ' node_modules/@astrojs/starlight/utils/routing' ;
99
10+ // custom component copied from starlight/components/LinkCard
11+ import CustomLinkCard from ' @components/plugins/CustomLinkCard.astro' ;
12+
1013interface Props {
1114 /**
1215 * Slug relative to /src - e.g "/zh-cn/features"
@@ -28,6 +31,11 @@ interface Props {
2831 * Use this to ignore sidebar order
2932 */
3033 sortAlphabetically? : boolean ;
34+
35+ /*
36+ * specifically to support compatibility footer in CustomLink card
37+ */
38+ callback? : Function ;
3139}
3240
3341function hasSidebarOrder(page : Route ): number | undefined {
@@ -43,7 +51,12 @@ function compareOrder(a: Route, b: Route): boolean {
4351}
4452
4553let { slug } = Astro .props ;
46- const { filterOutByTitle = [], filterOutByFileName = [], sortAlphabetically = false } = Astro .props ;
54+ const {
55+ filterOutByTitle = [],
56+ filterOutByFileName = [],
57+ sortAlphabetically = false ,
58+ callback,
59+ } = Astro .props ;
4760
4861const defaultLocale = config .defaultLocale .lang || ' en' ;
4962const localesList = config .isMultilingual ? Object .keys (config .locales ) : [defaultLocale ];
@@ -137,22 +150,26 @@ if (!sortAlphabetically) {
137150
138151<CardGrid >
139152 {
140- mainList .map ((item ) => (
141- <LinkCard
142- title = { item .entry .data .title }
143- href = { ` /${item .slug } ` }
144- description = { item .entry .data .description }
145- />
146- ))
153+ mainList .map ((item ) => {
154+ return (
155+ <CustomLinkCard
156+ title = { item .entry .data .title }
157+ href = { ` /${item .slug }/ ` }
158+ description = { item .entry .data .description }
159+ footer = { callback instanceof Function && callback (item .slug )}
160+ />
161+ );
162+ })
147163 }
148164 {
149165 locale !== defaultLocale &&
150166 fallbackList .map ((item ) => (
151- <LinkCard
167+ <CustomLinkCard
152168 class = " fallback-badge"
153169 title = { item .entry .data .title }
154- href = { ` /${item .slug } ` }
170+ href = { ` /${item .slug }/ ` }
155171 description = { item .entry .data .description }
172+ footer = { callback instanceof Function && callback (item .slug )}
156173 />
157174 ))
158175 }
0 commit comments