From a47751efbbf2e2fc9e93b030941820755be80f56 Mon Sep 17 00:00:00 2001 From: Ayc0 Date: Tue, 19 Aug 2025 21:40:39 +0200 Subject: [PATCH] enforce tags --- src/content/config.ts | 42 ++++++++++++++++++- .../posts/Others/monitoring-websockets.mdx | 2 +- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/content/config.ts b/src/content/config.ts index 765f891..1c3f620 100644 --- a/src/content/config.ts +++ b/src/content/config.ts @@ -1,6 +1,46 @@ import { defineCollection, z } from "astro:content"; import { docsSchema } from "@astrojs/starlight/schema"; +// TODO: clean those a bit +const tags = [ + "css", // Used 12 times + "webdev", // Used 10 times + "javascript", // Used 10 times + "react", // Used 8 times + "responsive", // Used 3 times + "typescript", // Used 3 times + "yarn", // Used 3 times + "tip", // Used 2 times + "package", // Used 2 times + "hooks", // Used 2 times + "migration", // Used 2 times + "config", // Used 2 times + "lockfile", // Used 2 times + "html", // Used 1 times + "fundamentals", // Used 1 times + "learn", // Used 1 times + "tutorial", // Used 1 times + "parcel", // Used 1 times + "bundler", // Used 1 times + "intl", // Used 1 times + "encoding", // Used 1 times + "unicode", // Used 1 times + "monitoring", // Used 1 times + "websocket", // Used 1 times + "discuss", // Used 1 times + "npm", // Used 1 times + "semver", // Used 1 times + "versioning", // Used 1 times + "lifecycle", // Used 1 times + "task", // Used 1 times + "async", // Used 1 times + "refs", // Used 1 times + "dom", // Used 1 times + "breakpoints", // Used 1 times + "operator", // Used 1 times + "berry", // Used 1 times +] as const; + export const collections = { docs: defineCollection({ schema: docsSchema({ @@ -47,7 +87,7 @@ export const collections = { // Required for published posts to have those defined description: z.string(), - tags: z.array(z.string()), // TODO: use a set list of tags to avoid typos + tags: z.array(z.enum(tags)), pagefind: z.literal(true).optional(), // Making sure that all public posts are searchable }), ), diff --git a/src/content/docs/posts/Others/monitoring-websockets.mdx b/src/content/docs/posts/Others/monitoring-websockets.mdx index 2b20175..aacd7f4 100644 --- a/src/content/docs/posts/Others/monitoring-websockets.mdx +++ b/src/content/docs/posts/Others/monitoring-websockets.mdx @@ -1,6 +1,6 @@ --- title: "Monitoring WebSockets" -tags: ["JavaScript", "Tip", "Monitoring", "WebSocket"] +tags: ["javascript", "tip", "monitoring", "websocket"] createdAt: 2024-12-23 lastUpdated: 2024-12-23 image: /src/assets/monitoring-websockets.png -- 2.51.2