feat: add collection for authors

This commit is contained in:
thomas
2023-11-23 22:42:42 +04:00
parent 311d8128b2
commit 6cb5c5c415
88 changed files with 192 additions and 117 deletions

View File

@@ -1,23 +1,38 @@
import { docsSchema, i18nSchema } from '@astrojs/starlight/schema';
import { defineCollection, z } from 'astro:content';
import { defineCollection, reference, z } from 'astro:content';
const authors = defineCollection({
type: 'data',
schema: z.object({
name: z.string(),
twitter: z.string().url().optional(),
linkedin: z.string().url().optional(),
github: z.string().url().optional(),
}),
});
const docs = defineCollection({
schema: (ctx) =>
docsSchema()(ctx).extend({
noCommentSection: z.boolean().optional().default(false),
challengeNumber: z.union([z.number(), z.boolean()]).default(false),
author: reference('authors').optional(),
command: z.string().optional(),
blogLink: z.string().optional(),
videoLink: z
.object({
link: z.string(),
alt: z.string(),
flag: z.enum(['FR']).optional(),
})
.optional(),
}),
});
const i18n = defineCollection({ type: 'data', schema: i18nSchema() });
export const collections = {
docs: defineCollection({
schema: (ctx) =>
docsSchema()(ctx).extend({
noCommentSection: z.boolean().optional().default(false),
challengeNumber: z.union([z.number(), z.boolean()]).default(false),
author: z.string().optional(),
command: z.string().optional(),
blogLink: z.string().optional(),
videoLink: z
.object({
link: z.string(),
alt: z.string(),
flag: z.enum(['FR']).optional(),
})
.optional(),
}),
}),
i18n: defineCollection({ type: 'data', schema: i18nSchema() }),
docs: docs,
i18n: i18n,
authors: authors,
};