Add description exports and collapse characters from same user
This commit is contained in:
parent
2990644f87
commit
d4a9dc9dbc
78 changed files with 693 additions and 247 deletions
|
|
@ -1,39 +1,52 @@
|
|||
import { defineCollection, reference, z } from "astro:content";
|
||||
|
||||
const user = z.union([z.string(), z.record(z.string().url())]);
|
||||
export const WEBSITE_LIST = [
|
||||
"website",
|
||||
"eka",
|
||||
"furaffinity",
|
||||
"weasyl",
|
||||
"inkbunny",
|
||||
"sofurry",
|
||||
"twitter",
|
||||
"mastodon",
|
||||
"bluesky",
|
||||
] as const;
|
||||
|
||||
const lang = z.enum(["eng", "tok"]).default("eng");
|
||||
const website = z.enum(WEBSITE_LIST);
|
||||
|
||||
export type User = z.output<typeof user>;
|
||||
export type Lang = z.output<typeof lang>;
|
||||
export type Website = z.infer<typeof website>;
|
||||
|
||||
const storiesCollection = defineCollection({
|
||||
type: "content",
|
||||
schema: ({ image }) =>
|
||||
z.object({
|
||||
// Required
|
||||
title: z.string(),
|
||||
shortTitle: z.string().optional(),
|
||||
pubDate: z.date(),
|
||||
isDraft: z.boolean().default(false),
|
||||
authors: z.union([user, z.array(user)]).default("Bad Manners"),
|
||||
wordCount: z.number().int(),
|
||||
contentWarning: z.string(),
|
||||
description: z.string(),
|
||||
tags: z.array(z.string()),
|
||||
// Optional
|
||||
isDraft: z.boolean().default(false),
|
||||
shortTitle: z.string().optional(),
|
||||
authors: z.union([reference("users"), z.array(reference("users"))]).default("bad-manners"),
|
||||
descriptionPlaintext: z.string().optional(),
|
||||
summary: z.string().optional(),
|
||||
thumbnail: image().optional(),
|
||||
thumbnailWidth: z.number().int().optional(),
|
||||
thumbnailHeight: z.number().int().optional(),
|
||||
tags: z.array(z.string()),
|
||||
series: z.record(z.string(), z.string()).optional(),
|
||||
commissioner: user.optional(),
|
||||
requester: user.optional(),
|
||||
copyrightedCharacters: z.record(z.string(), user).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(),
|
||||
relatedStories: z.array(reference("stories")).optional(),
|
||||
relatedGames: z.array(reference("games")).optional(),
|
||||
relatedStories: z.array(reference("stories")).default([]),
|
||||
relatedGames: z.array(reference("games")).default([]),
|
||||
}),
|
||||
});
|
||||
|
||||
|
|
@ -41,26 +54,43 @@ const gamesCollection = defineCollection({
|
|||
type: "content",
|
||||
schema: ({ image }) =>
|
||||
z.object({
|
||||
// Required
|
||||
title: z.string(),
|
||||
pubDate: z.date(),
|
||||
isDraft: z.boolean().default(false),
|
||||
authors: z.union([user, z.array(user)]).default("Bad Manners"),
|
||||
contentWarning: z.string(),
|
||||
description: z.string(),
|
||||
tags: z.array(z.string()),
|
||||
// Optional
|
||||
isDraft: z.boolean().default(false),
|
||||
authors: z.union([reference("users"), z.array(reference("users"))]).default("bad-manners"),
|
||||
descriptionPlaintext: z.string().optional(),
|
||||
thumbnail: image().optional(),
|
||||
thumbnailWidth: z.number().int().optional(),
|
||||
thumbnailHeight: z.number().int().optional(),
|
||||
tags: z.array(z.string()),
|
||||
series: z.record(z.string(), z.string()).optional(),
|
||||
copyrightedCharacters: z.record(z.string(), user).optional(),
|
||||
copyrightedCharacters: z.record(z.string(), reference("users")).default({}),
|
||||
lang,
|
||||
relatedStories: z.array(reference("stories")).optional(),
|
||||
relatedGames: z.array(reference("games")).optional(),
|
||||
relatedStories: z.array(reference("stories")).default([]),
|
||||
relatedGames: z.array(reference("games")).default([]),
|
||||
}),
|
||||
});
|
||||
|
||||
const usersCollection = defineCollection({
|
||||
type: "data",
|
||||
schema: ({ image }) =>
|
||||
z.object({
|
||||
// Required
|
||||
name: z.string(),
|
||||
links: z.record(website, z.union([z.string().url(), z.tuple([z.string().url(), z.string()])])),
|
||||
preferredLink: website.nullable(),
|
||||
// Optional
|
||||
nameLang: z.record(lang, z.string()).default({}),
|
||||
avatar: image().optional(),
|
||||
}),
|
||||
});
|
||||
|
||||
export const collections = {
|
||||
stories: storiesCollection,
|
||||
games: gamesCollection,
|
||||
users: usersCollection,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue