Improvements to types and age verification screen
This commit is contained in:
parent
18e98cdb3b
commit
7f7a62a391
78 changed files with 1132 additions and 1102 deletions
|
|
@ -13,6 +13,8 @@ export const WEBSITE_LIST = [
|
|||
"itaku",
|
||||
] as const;
|
||||
|
||||
const localUrlRegex = /^((\/?\.\.(?=\/))+|(\.(?=\/)))?\/?[a-z0-9_-]+(\/[a-z0-9_-]+)*\/?$/;
|
||||
|
||||
const lang = z.enum(["eng", "tok"]).default("eng");
|
||||
const website = z.enum(WEBSITE_LIST);
|
||||
|
||||
|
|
@ -39,13 +41,13 @@ const storiesCollection = defineCollection({
|
|||
thumbnail: image().optional(),
|
||||
thumbnailWidth: z.number().int().optional(),
|
||||
thumbnailHeight: z.number().int().optional(),
|
||||
series: z.record(z.string(), z.string()).optional(),
|
||||
series: reference("series").optional(),
|
||||
commissioner: reference("users").optional(),
|
||||
requester: reference("users").optional(),
|
||||
copyrightedCharacters: z.record(z.string(), reference("users")).default({}),
|
||||
lang,
|
||||
prev: reference("stories").nullable().optional(),
|
||||
next: reference("stories").nullable().optional(),
|
||||
prev: reference("stories").nullish(),
|
||||
next: reference("stories").nullish(),
|
||||
relatedStories: z.array(reference("stories")).default([]),
|
||||
relatedGames: z.array(reference("games")).default([]),
|
||||
}),
|
||||
|
|
@ -68,7 +70,7 @@ const gamesCollection = defineCollection({
|
|||
thumbnail: image().optional(),
|
||||
thumbnailWidth: z.number().int().optional(),
|
||||
thumbnailHeight: z.number().int().optional(),
|
||||
series: z.record(z.string(), z.string()).optional(),
|
||||
series: reference("series").optional(),
|
||||
copyrightedCharacters: z.record(z.string(), reference("users")).default({}),
|
||||
lang,
|
||||
relatedStories: z.array(reference("stories")).default([]),
|
||||
|
|
@ -83,13 +85,23 @@ const usersCollection = defineCollection({
|
|||
// Required
|
||||
name: z.string(),
|
||||
links: z.record(website, z.union([z.string().url(), z.tuple([z.string().url(), z.string()])])),
|
||||
preferredLink: website.nullable(),
|
||||
// Optional
|
||||
preferredLink: website.nullish(),
|
||||
nameLang: z.record(lang, z.string()).default({}),
|
||||
avatar: image().optional(),
|
||||
isAnonymous: z.boolean().default(false),
|
||||
}),
|
||||
});
|
||||
|
||||
const seriesCollection = defineCollection({
|
||||
type: "data",
|
||||
schema: z.object({
|
||||
// Required
|
||||
name: z.string(),
|
||||
url: z.string().regex(localUrlRegex, "must be a local URL"),
|
||||
}),
|
||||
});
|
||||
|
||||
const tagCategoriesCollection = defineCollection({
|
||||
type: "data",
|
||||
schema: z.object({
|
||||
|
|
@ -101,8 +113,11 @@ const tagCategoriesCollection = defineCollection({
|
|||
});
|
||||
|
||||
export const collections = {
|
||||
// Content collections
|
||||
stories: storiesCollection,
|
||||
games: gamesCollection,
|
||||
// Data collections
|
||||
users: usersCollection,
|
||||
series: seriesCollection,
|
||||
"tag-categories": tagCategoriesCollection,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue