summaryrefslogtreecommitdiff
path: root/source.config.ts
diff options
context:
space:
mode:
Diffstat (limited to 'source.config.ts')
-rw-r--r--source.config.ts55
1 files changed, 55 insertions, 0 deletions
diff --git a/source.config.ts b/source.config.ts
new file mode 100644
index 0000000..9ff650e
--- /dev/null
+++ b/source.config.ts
@@ -0,0 +1,55 @@
+import { transformerRemoveNotationEscape } from '@shikijs/transformers';
+import { rehypeCodeDefaultOptions } from 'fumadocs-core/mdx-plugins';
+import {
+ defineCollections,
+ defineConfig,
+ frontmatterSchema,
+} from 'fumadocs-mdx/config';
+import { transformerTwoslash } from 'fumadocs-twoslash';
+import rehypeKatex from 'rehype-katex';
+import remarkMath from 'remark-math';
+import { z } from 'zod';
+
+export const blog = defineCollections({
+ type: 'doc',
+ dir: 'content',
+ schema: frontmatterSchema.extend({
+ date: z
+ .string()
+ .or(z.date())
+ .transform((value, context) => {
+ try {
+ return new Date(value);
+ } catch {
+ context.addIssue({
+ code: z.ZodIssueCode.custom,
+ message: 'Invalid date',
+ });
+ return z.NEVER;
+ }
+ }),
+ author: z.string(),
+ tags: z.array(z.string()).optional(),
+ image: z.string().optional(),
+ }),
+});
+
+export default defineConfig({
+ lastModifiedTime: 'git',
+ mdxOptions: {
+ rehypeCodeOptions: {
+ inline: 'tailing-curly-colon',
+ themes: {
+ light: 'catppuccin-latte',
+ dark: 'catppuccin-mocha',
+ },
+ transformers: [
+ ...(rehypeCodeDefaultOptions.transformers ?? []),
+ transformerTwoslash(),
+ transformerRemoveNotationEscape(),
+ ],
+ },
+ remarkPlugins: [remarkMath],
+ rehypePlugins: (v) => [rehypeKatex, ...v],
+ },
+});