aboutsummaryrefslogtreecommitdiff
path: root/website/src/content.config.ts
blob: c9a9b8fd366002b3033f96d9f2f8d7fdb2328c2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { defineCollection, z } from 'astro:content';
import { glob } from 'astro/loaders';
import { docsLoader } from '@astrojs/starlight/loaders';
import { docsSchema } from '@astrojs/starlight/schema';

function docsPath({ entry }: { entry: string }) {
  const slug = entry.replace(/\.(md|mdx|markdown|mdown|mkdn|mkd|mdwn)$/i, '');
  return slug === 'index' ? 'docs' : `docs/${slug}`;
}

export const collections = {
  docs: defineCollection({ loader: docsLoader({ generateId: docsPath }), schema: docsSchema() }),
  blog: defineCollection({
    loader: glob({ pattern: '*.md', base: './src/content/blog' }),
    schema: z.object({
      title: z.string(),
      description: z.string(),
      date: z.coerce.date(),
      draft: z.boolean().default(false),
    }),
  }),
  releases: defineCollection({
    loader: glob({ pattern: '*.md', base: './src/content/releases' }),
    schema: z.object({
      title: z.string(),
      version: z.string(),
      path: z.string(),
      description: z.string(),
      date: z.coerce.date(),
      draft: z.boolean().default(false),
    }),
  }),
};