@@ -29,6 +29,8 @@ export const docSchema = {
29
29
headings : headingSchema ,
30
30
}
31
31
32
+ export const allowedExtensions = [ "mdx" , "tsx" , "ts" ]
33
+
32
34
export const AriaDocsCollection = new Directory ( {
33
35
path : "content/docs/aria-docs" ,
34
36
// base path is required, otherwise we can't build the correct slugs in the `generateStaticParams`
@@ -38,6 +40,8 @@ export const AriaDocsCollection = new Directory({
38
40
docSchema ,
39
41
( path ) => import ( `@content/docs/aria-docs/${ path } .mdx` ) ,
40
42
) ,
43
+ tsx : withSchema ( ( path ) => import ( `@content/docs/aria-docs/${ path } .tsx` ) ) ,
44
+ ts : withSchema ( ( path ) => import ( `@content/docs/aria-docs/${ path } .ts` ) ) ,
41
45
} ,
42
46
} )
43
47
@@ -50,6 +54,8 @@ export const RenounDocsCollection = new Directory({
50
54
docSchema ,
51
55
( path ) => import ( `@content/docs/renoun-docs/${ path } .mdx` ) ,
52
56
) ,
57
+ tsx : withSchema ( ( path ) => import ( `@content/docs/renoun-docs/${ path } .tsx` ) ) ,
58
+ ts : withSchema ( ( path ) => import ( `@content/docs/renoun-docs/${ path } .ts` ) ) ,
53
59
} ,
54
60
} )
55
61
@@ -62,6 +68,12 @@ export const TestCollection = new Directory({
62
68
docSchema ,
63
69
( path ) => import ( `@content/docs/test-collection/${ path } .mdx` ) ,
64
70
) ,
71
+ tsx : withSchema (
72
+ ( path ) => import ( `@content/docs/test-collection/${ path } .tsx` ) ,
73
+ ) ,
74
+ ts : withSchema (
75
+ ( path ) => import ( `@content/docs/test-collection/${ path } .ts` ) ,
76
+ ) ,
65
77
} ,
66
78
} )
67
79
@@ -76,12 +88,10 @@ export type DirectoryType = Awaited<
76
88
77
89
export async function getDirectoryContent ( source : EntryType ) {
78
90
// first, try to get the file based on the given path
79
- try {
80
- return await CollectionInfo . getDirectory ( source . getPathSegments ( ) )
81
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
82
- } catch ( e : unknown ) {
83
- return null
84
- }
91
+
92
+ return await CollectionInfo . getDirectory ( source . getPathSegments ( ) ) . catch (
93
+ ( ) => null ,
94
+ )
85
95
}
86
96
87
97
/**
@@ -94,20 +104,15 @@ export async function getDirectoryContent(source: EntryType) {
94
104
*/
95
105
export async function getFileContent ( source : EntryType ) {
96
106
// first, try to get the file based on the given path
97
- try {
98
- return await CollectionInfo . getFile ( source . getPathSegments ( ) , "mdx" )
99
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
100
- } catch ( e : unknown ) {
101
- try {
107
+
108
+ return await CollectionInfo . getFile ( source . getPathSegments ( ) , "mdx" ) . catch (
109
+ async ( ) => {
102
110
return await CollectionInfo . getFile (
103
111
[ ...source . getPathSegments ( ) , "index" ] ,
104
112
"mdx" ,
105
- )
106
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
107
- } catch ( e : unknown ) {
108
- return null
109
- }
110
- }
113
+ ) . catch ( ( ) => null )
114
+ } ,
115
+ )
111
116
}
112
117
113
118
/**
0 commit comments