mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 07:33:07 +08:00
2827d4e7d8
* refactor: replace postSlug with Astro content slug Remove postSlug from blog schema. Refactor articles that use postSlug. Remove slugify function from slugify util file. Replace slugify logic with Astro's content collections slug logic. Closes: #186 * docs: update docs for removed slugify contents * refactor: remove unused import
27 lines
790 B
TypeScript
27 lines
790 B
TypeScript
import { SITE } from "@config";
|
|
import { defineCollection, z } from "astro:content";
|
|
|
|
const blog = defineCollection({
|
|
type: "content",
|
|
schema: ({ image }) =>
|
|
z.object({
|
|
author: z.string().default(SITE.author),
|
|
pubDatetime: z.date(),
|
|
modDatetime: z.date().optional(),
|
|
title: z.string(),
|
|
featured: z.boolean().optional(),
|
|
draft: z.boolean().optional(),
|
|
tags: z.array(z.string()).default(["others"]),
|
|
ogImage: image()
|
|
.refine(img => img.width >= 1200 && img.height >= 630, {
|
|
message: "OpenGraph image must be at least 1200 X 630 pixels!",
|
|
})
|
|
.or(z.string())
|
|
.optional(),
|
|
description: z.string(),
|
|
canonicalURL: z.string().optional(),
|
|
}),
|
|
});
|
|
|
|
export const collections = { blog };
|