Add platforms to GameLayout

This commit is contained in:
Bad Manners 2024-04-12 18:15:03 -03:00
parent 877c02ccfc
commit 837433364d
16 changed files with 144 additions and 42 deletions

View file

@ -22,6 +22,7 @@ const refineCopyrightedCharacters = (value: Record<string, any>) => !("" in valu
const lang = z.enum(["eng", "tok"]).default("eng");
const website = z.enum(WEBSITE_LIST);
const platform = z.enum(["web", "windows", "linux", "macos", "android", "ios"]);
const mastodonPost = z.object({
instance: z.string(),
user: z.string(),
@ -48,7 +49,7 @@ const storiesCollection = defineCollection({
authors: z
.union([reference("users"), z.array(reference("users"))])
.default("bad-manners")
.refine(refineAuthors, "authors cannot be empty"),
.refine(refineAuthors, `"authors" cannot be empty`),
descriptionPlaintext: z.string().optional(),
summary: z.string().optional(),
thumbnail: image().optional(),
@ -60,10 +61,7 @@ const storiesCollection = defineCollection({
copyrightedCharacters: z
.record(z.string(), reference("users"))
.default({})
.refine(
refineCopyrightedCharacters,
"copyrightedCharacters cannot have an empty catch-all key with other keys",
),
.refine(refineCopyrightedCharacters, `"copyrightedCharacters" cannot mix empty catch-all key with other keys`),
lang,
prev: reference("stories").nullish(),
next: reference("stories").nullish(),
@ -88,19 +86,17 @@ const gamesCollection = defineCollection({
authors: z
.union([reference("users"), z.array(reference("users"))])
.default("bad-manners")
.refine(refineAuthors, "authors cannot be empty"),
.refine(refineAuthors, `"authors" cannot be empty`),
descriptionPlaintext: z.string().optional(),
thumbnail: image().optional(),
thumbnailWidth: z.number().int().optional(),
thumbnailHeight: z.number().int().optional(),
series: reference("series").optional(),
platforms: z.array(platform).refine((platforms) => platforms.length > 0, `"platforms" cannot be empty`),
copyrightedCharacters: z
.record(z.string(), reference("users"))
.default({})
.refine(
refineCopyrightedCharacters,
"copyrightedCharacters cannot have an empty catch-all key with other keys",
),
.refine(refineCopyrightedCharacters, `"copyrightedCharacters" cannot mix empty catch-all key with other keys`),
lang,
relatedStories: z.array(reference("stories")).default([]),
relatedGames: z.array(reference("games")).default([]),
@ -125,7 +121,7 @@ const usersCollection = defineCollection({
.refine(
({ links, preferredLink }) => !preferredLink || preferredLink in links,
({ preferredLink }) => ({
message: `"${preferredLink}" not defined in links`,
message: `"${preferredLink}" not defined in "links"`,
path: ["preferredLink"],
}),
),
@ -136,7 +132,7 @@ const seriesCollection = defineCollection({
schema: z.object({
// Required
name: z.string(),
url: z.string().regex(localUrlRegex, "must be a local URL"),
url: z.string().regex(localUrlRegex, `"url" must be a local URL`),
}),
});
@ -149,7 +145,7 @@ const tagCategoriesCollection = defineCollection({
tags: z.array(
z.union([
z.string(),
z.record(lang, z.string()).refine((tag) => "eng" in tag, 'Object-formatted tag must have an "eng" key'),
z.record(lang, z.string()).refine((tag) => "eng" in tag, `object-formatted tag must have an "eng" key`),
]),
),
}),