Simple conetent + restyled

This commit is contained in:
2026-09-21 17:59:29 +02:00
parent 0772462742
commit 467bf77d34
55 changed files with 2162 additions and 2070 deletions
+18 -33
View File
@@ -1,41 +1,26 @@
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';
import examples from './data/examples.json';
// News/articles live as Markdown files in src/content/news/*.md.
// This is exactly what Sveltia CMS edits — the CMS writes these files, Astro
// renders them to static HTML at build time.
const news = defineCollection({
// Top-level only ('*.md', not '**'): entry ids feed a non-rest [slug]
// route, and an id from a subfolder would contain '/' and break it.
loader: glob({ pattern: '*.md', base: './src/content/news' }),
schema: z.object({
title: z.string(),
description: z.string(),
date: z.coerce.date(),
category: z.string().default('news'),
author: z.string().default('CTAO'),
// Public-path string, e.g. "/uploads/foo.jpg" — media lives in the
// content repo's uploads/, overlaid to public/uploads at build time,
// which Astro's image() helper can't validate (src/ only).
cover: z.string().optional(),
// BCP-47 tag when an article is not in English (e.g. "pl") — set as lang
// on the <article> element so screen readers pick the right voice.
lang: z.string().optional(),
draft: z.boolean().default(false),
}),
});
// Static portal pages (privacy, disclaimer, contact…) — separate collection
// because the content type differs (no dates/covers/categories), and editors
// get a distinct "Pages" section in the CMS.
const destination = z.string().refine(
(value) => !value || /^(\/(?!\/)|https?:\/\/|mailto:|#)/.test(value),
'Use a site path, https:// URL, mailto: address, or fragment.',
);
const pages = defineCollection({
// Top-level only, same reason as news: the [slug] route is non-rest.
loader: glob({ pattern: '*.md', base: './src/content/pages' }),
// Only these four files can become public content pages.
loader: glob({
pattern: `{${examples.map(({ slug }) => slug).join(',')}}.md`,
base: './src/content/pages',
}),
schema: z.object({
title: z.string(),
description: z.string().optional(),
title: z.string().min(1),
introduction: z.string().optional(),
image: z.string().optional(),
imageAlt: z.string().optional(),
imageCaption: z.string().optional(),
buttonLabel: z.string().optional(),
buttonUrl: destination.optional(),
}),
});
export const collections = { news, pages };
export const collections = { pages };