summaryrefslogtreecommitdiff
path: root/source.config.ts
diff options
context:
space:
mode:
authorBertrand Yuan <bert.yuan@outlook.com>2025-12-15 23:48:10 +0800
committerBertrand Yuan <bert.yuan@outlook.com>2025-12-15 23:48:10 +0800
commit5b7ccf0b671e2999b62befc729a3e517a0433728 (patch)
tree8bf476dc7c75914c221042546840dc76267366df /source.config.ts
initial commit -- the front-end prototype
The initial code is base on Anirudh's work. More to see at: https://github.com/techwithanirudh/shadcn-blog Therefore, the code in this commit is under MIT license.
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],
+ },
+});