File tree 3 files changed +38
-44
lines changed
3 files changed +38
-44
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ import { type CollectionEntry } from " astro:content" ;
3
+ import BaseLayout from " ./BaseLayout.astro" ;
4
+ import { makeReferencePageSlug } from " @pages/_utils" ;
5
+ import { removeLocalePrefix } from " @i18n/utils" ;
6
+
7
+ type ReferenceEntry = CollectionEntry <" reference" >;
8
+
9
+ interface Props {
10
+ title: string ;
11
+ entries: ReferenceEntry [];
12
+ }
13
+
14
+ const { entries, title } = Astro .props ;
15
+ ---
16
+
17
+ <BaseLayout title ={ title } >
18
+ <ul >
19
+ {
20
+ entries .map ((refEntry ) => (
21
+ <li >
22
+ <a
23
+ href = { ` /reference${makeReferencePageSlug (removeLocalePrefix (refEntry .id ))} ` }
24
+ >
25
+ { refEntry .data .title }
26
+ </a >
27
+ </li >
28
+ ))
29
+ }
30
+ </ul >
31
+ </BaseLayout >
Original file line number Diff line number Diff line change 1
1
---
2
- import BaseLayout from " @layouts/BaseLayout .astro" ;
2
+ import ReferenceLayout from " @layouts/ReferenceLayout .astro" ;
3
3
import { nonDefaultSupportedLocales } from " @i18n/const" ;
4
- import {
5
- getCollectionInLocaleWithFallbacks ,
6
- makeReferencePageSlug ,
7
- } from " @pages/_utils" ;
8
- import { removeLocalePrefix } from " @i18n/utils" ;
4
+ import { getCollectionInLocaleWithFallbacks } from " @pages/_utils" ;
9
5
10
6
export async function getStaticPaths() {
11
7
const paths = nonDefaultSupportedLocales .map (async (locale ) => ({
@@ -20,22 +16,7 @@ export async function getStaticPaths() {
20
16
return await Promise .all (paths );
21
17
}
22
18
23
- const { locale } = Astro .params ;
24
19
const { entries } = Astro .props ;
25
20
---
26
21
27
- <BaseLayout title =" Reference" >
28
- <ul >
29
- {
30
- entries .map ((refEntry ) => (
31
- <li >
32
- <a
33
- href = { ` /${locale }/reference${makeReferencePageSlug (removeLocalePrefix (refEntry .id ))} ` }
34
- >
35
- { refEntry .data .title }
36
- </a >
37
- </li >
38
- ))
39
- }
40
- </ul >
41
- </BaseLayout >
22
+ <ReferenceLayout title =" Reference" entries ={ entries } />
Original file line number Diff line number Diff line change 1
1
---
2
- import BaseLayout from " @layouts/BaseLayout.astro" ;
3
- import {
4
- getCollectionInDefaultLocale ,
5
- makeReferencePageSlug ,
6
- } from " @pages/_utils" ;
7
- import { removeLocalePrefix } from " @i18n/utils" ;
2
+ import ReferenceLayout from " @layouts/ReferenceLayout.astro" ;
3
+ import { getCollectionInDefaultLocale } from " @pages/_utils" ;
8
4
9
- const referenceEntries = await getCollectionInDefaultLocale (" reference" );
5
+ const entries = await getCollectionInDefaultLocale (" reference" );
10
6
---
11
7
12
- <BaseLayout title =" Reference" >
13
- <ul >
14
- {
15
- referenceEntries .map ((refEntry ) => (
16
- <li >
17
- <a
18
- href = { ` /reference/${makeReferencePageSlug (removeLocalePrefix (refEntry .id ))} ` }
19
- >
20
- { refEntry .data .title }
21
- </a >
22
- </li >
23
- ))
24
- }
25
- </ul >
26
- </BaseLayout >
8
+ <ReferenceLayout title =" Reference" entries ={ entries } />
You can’t perform that action at this time.
0 commit comments