Skip to content

Commit

Permalink
update export value definition
Browse files Browse the repository at this point in the history
  • Loading branch information
noxify committed Jan 23, 2025
1 parent 09a8788 commit 6e4c154
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions src/collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,24 @@ export const frontmatterSchema = z.object({
alias: z.string().optional(),
})

export const headingSchema = z.object({
depth: z.number(),
text: z.string(),
id: z.string(),
})

interface DocSchema {
frontmatter: z.infer<typeof frontmatterSchema>
headings: z.infer<typeof headingSchema>[]
}
export const headingSchema = z.array(
z.object({
depth: z.number(),
text: z.string(),
id: z.string(),
}),
)

export const AriaDocsCollection = new Directory({
path: "content/docs/aria-docs",
// base path is required, otherwise we can't build the correct slugs in the `generateStaticParams`
basePath: "aria-docs",
loaders: {
mdx: withSchema<DocSchema>(
mdx: withSchema(
{
frontmatter: frontmatterSchema,
headings: headingSchema,
},
(path) => import(`@content/docs/aria-docs/${path}.mdx`),
),
},
Expand All @@ -43,7 +44,11 @@ export const RenounDocsCollection = new Directory({
// base path is required, otherwise we can't build the correct slugs in the `generateStaticParams`
basePath: "renoun-docs",
loaders: {
mdx: withSchema<DocSchema>(
mdx: withSchema(
{
frontmatter: frontmatterSchema,
headings: headingSchema,
},
(path) => import(`@content/docs/renoun-docs/${path}.mdx`),
),
},
Expand All @@ -54,7 +59,11 @@ export const TestCollection = new Directory({
// base path is required, otherwise we can't build the correct slugs in the `generateStaticParams`
basePath: "test-collection",
loaders: {
mdx: withSchema<DocSchema>(
mdx: withSchema(
{
frontmatter: frontmatterSchema,
headings: headingSchema,
},
(path) => import(`@content/docs/test-collection/${path}.mdx`),
),
},
Expand Down

0 comments on commit 6e4c154

Please sign in to comment.