@@ -9,19 +9,49 @@ description:
9
9
10
10
import { Cards } from ' nextra/components'
11
11
import { FileIcon , FolderIcon , MdxIcon } from ' nextra/icons'
12
- import { MDXRemote } from ' nextra/mdx-remote '
13
- import { createIndexPage , getPageMap } from ' nextra/page-map '
12
+ import { getIndexPageMap , getPageMap } from ' nextra/page-map '
13
+ import { useMDXComponents } from ' ../../../mdx-components '
14
14
15
15
# File Conventions
16
16
17
- <MDXRemote
18
- compiledSource = { await createIndexPage (
19
- await getPageMap (' /docs/file-conventions' )
20
- )}
21
- components = { {
17
+ export async function Page() {
18
+ const { h2 : H2 } = useMDXComponents ()
19
+ const currentRoute = metadata .filePath
20
+ .replace (' app' , ' ' )
21
+ .replace (' /page.mdx' , ' ' )
22
+ const pageMap = await getPageMap (currentRoute )
23
+ const icons = {
22
24
Cards ,
23
25
FileIcon ,
24
26
FolderIcon ,
25
27
MdxIcon
26
- }}
27
- />
28
+ }
29
+ return getIndexPageMap (pageMap ).map (pageItem => {
30
+ if (! Array .isArray (pageItem )) {
31
+ return <H2 >{ pageItem .title } </H2 >
32
+ }
33
+ return (
34
+ <Cards >
35
+ { pageItem .map (item => {
36
+ const icon = item .frontMatter ?.icon
37
+ const Icon = icons [icon ]
38
+ if (icon && ! Icon ) {
39
+ throw new Error (
40
+ " Icon is defined in front matter but isn't provided"
41
+ )
42
+ }
43
+ return (
44
+ <Cards.Card
45
+ key = { item .name }
46
+ title = { item .title }
47
+ href = { item .route || item .href }
48
+ icon = { Icon && <Icon />}
49
+ />
50
+ )
51
+ })}
52
+ </Cards >
53
+ )
54
+ })
55
+ }
56
+
57
+ <Page />
0 commit comments