feat: allow blog posts to be organized by subdirectories

Blog posts can now be structured into subdirectories, which determine their slugs.

Example:
- `/src/data/blog/2025/testing.md` → `/posts/2025/testing`

Directories prefixed with `_` will be excluded from the slug.

Example:
- `/src/data/blog/_examples/tailwind-typography.md` → `/posts/tailwind-typography`

Closes #470, #366
This commit is contained in:
satnaing
2025-03-16 20:09:03 +07:00
committed by Sat Naing
parent 67b9536cce
commit feaf5e122a
19 changed files with 64 additions and 39 deletions
+3 -1
View File
@@ -2,8 +2,10 @@ import { defineCollection, z } from "astro:content";
import { glob } from "astro/loaders";
import { SITE } from "@/config";
export const BLOG_PATH = "src/data/blog";
const blog = defineCollection({
loader: glob({ pattern: "**/[^_]*.md", base: "./src/data/blog" }),
loader: glob({ pattern: "**/[^_]*.md", base: `./${BLOG_PATH}` }),
schema: ({ image }) =>
z.object({
author: z.string().default(SITE.author),