validation
souporserious opened this issue · comments
Travis Arnold commented
Validating MDX
Content can be typed using a simplified export of zod, in general anything should be able to run through this schema as a function:
import { createMDXTSPlugin } from 'mdxts/next'
import { array, date, string } from 'mdxts/value'
const withMDXTS = createMDXTSPlugin({
gitSource: 'https://github.com/souporserious/mdxts/tree/main',
sources: {
docs: {
include: 'docs/**/*.(tsx|mdx)',
schema: {
title: string(),
date: date({
requiredMessage: 'A date is required for all docs.',
invalidMessage: 'The provided date is invalid.',
}),
tags: array().optional()
}
},
},
})
export default withMDXTS({
experimental: {
appDir: true,
},
})
export const title = "How to report errors"
export const date = "2023-02-22"
export const tags = ["react", "css", "animation"]
This is an example of exporting metadata from MDX.
Validating code blocks
Code blocks should also be validated similar to shiki-twoslash.
Related
Travis Arnold commented
This is done now using Front Matter.