mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-16 19:51:07 +02:00
feat: add custom slug validation and handling for posts
- Enhance content configuration with slug validation to ensure only valid characters are used - Update post routing to support custom slugs with fallback to default slug - Implement slug duplication check to prevent conflicts across different languages - Modify various page components to use custom or default slugs in URL generation
This commit is contained in:
parent
ee35006f7c
commit
a26031d490
10 changed files with 67 additions and 11 deletions
|
@ -11,7 +11,19 @@ const postsCollection = defineCollection({
|
|||
image: z.string().optional().default(''),
|
||||
// Extended Settings
|
||||
lang: z.string().optional().default(''),
|
||||
slug: z.string().optional().default(''),
|
||||
slug: z.string()
|
||||
.optional()
|
||||
.default('')
|
||||
.refine(
|
||||
(slug) => {
|
||||
if (!slug)
|
||||
return true
|
||||
return /^[\w\-]*$/.test(slug)
|
||||
},
|
||||
{
|
||||
message: 'Slug can only contain letters, numbers, hyphens and underscores',
|
||||
},
|
||||
),
|
||||
toc: z.boolean().optional().default(false),
|
||||
pin: z.boolean().optional().default(false),
|
||||
draft: z.boolean().optional().default(false),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue