chore: add toc theme config option and update theme guides

This commit is contained in:
radishzzz 2025-05-18 17:23:32 +01:00
parent 94f9998f45
commit eb82a7d2f2
14 changed files with 121 additions and 15 deletions

View file

@ -1,6 +1,6 @@
import { glob } from 'astro/loaders'
import { defineCollection, z } from 'astro:content'
import { allLocales } from '@/config'
import { allLocales, themeConfig } from '@/config'
const posts = defineCollection({
loader: glob({ pattern: '**/*.{md,mdx}', base: './src/content/posts' }),
@ -15,7 +15,7 @@ const posts = defineCollection({
// Advanced
draft: z.boolean().optional().default(false),
pin: z.number().int().min(0).max(99).optional().default(0),
toc: z.boolean().optional().default(true),
toc: z.boolean().optional().default(themeConfig.global.toc),
lang: z.enum(['', ...allLocales]).optional().default(''),
abbrlink: z.string().optional().default('').refine(
abbrlink => !abbrlink || /^[a-z0-9\-]*$/.test(abbrlink),