@@ -4,9 +4,12 @@ import {
4
4
stripLeadingAndTrailingSlashes ,
5
5
ensureTrailingSlash ,
6
6
} from ' node_modules/@astrojs/starlight/utils/path' ;
7
- import { LinkCard , CardGrid } from ' @astrojs/starlight/components' ;
7
+ import { CardGrid } from ' @astrojs/starlight/components' ;
8
8
import { routes , type Route } from ' node_modules/@astrojs/starlight/utils/routing' ;
9
9
10
+ // custom component copied from starlight/components/LinkCard
11
+ import CustomLinkCard from ' @components/plugins/CustomLinkCard.astro' ;
12
+
10
13
interface Props {
11
14
/**
12
15
* Slug relative to /src - e.g "/zh-cn/features"
@@ -28,6 +31,11 @@ interface Props {
28
31
* Use this to ignore sidebar order
29
32
*/
30
33
sortAlphabetically? : boolean ;
34
+
35
+ /*
36
+ * specifically to support compatibility footer in CustomLink card
37
+ */
38
+ callback? : Function ;
31
39
}
32
40
33
41
function hasSidebarOrder(page : Route ): number | undefined {
@@ -43,7 +51,12 @@ function compareOrder(a: Route, b: Route): boolean {
43
51
}
44
52
45
53
let { 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 ;
47
60
48
61
const defaultLocale = config .defaultLocale .lang || ' en' ;
49
62
const localesList = config .isMultilingual ? Object .keys (config .locales ) : [defaultLocale ];
@@ -137,22 +150,26 @@ if (!sortAlphabetically) {
137
150
138
151
<CardGrid >
139
152
{
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
+ })
147
163
}
148
164
{
149
165
locale !== defaultLocale &&
150
166
fallbackList .map ((item ) => (
151
- <LinkCard
167
+ <CustomLinkCard
152
168
class = " fallback-badge"
153
169
title = { item .entry .data .title }
154
- href = { ` /${item .slug } ` }
170
+ href = { ` /${item .slug }/ ` }
155
171
description = { item .entry .data .description }
172
+ footer = { callback instanceof Function && callback (item .slug )}
156
173
/>
157
174
))
158
175
}
0 commit comments