CTAO Science Portal: static Astro site with git-based CMS (Sveltia + Gitea)

Portal code only; editorial content lives in the ctao/content repo on the
demo machine's Gitea and is overlaid at build time (see README.md and
deploy/README.md). Live demo: https://astro.isl-dev.grid.cyfronet.pl
This commit is contained in:
2026-09-08 13:53:30 +02:00
parent 845c1ccf0d
commit 0772462742
50 changed files with 11564 additions and 44 deletions
+41
View File
@@ -0,0 +1,41 @@
import { defineCollection } from 'astro:content';
import { z } from 'astro/zod';
import { glob } from 'astro/loaders';
// 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 pages = defineCollection({
// Top-level only, same reason as news: the [slug] route is non-rest.
loader: glob({ pattern: '*.md', base: './src/content/pages' }),
schema: z.object({
title: z.string(),
description: z.string().optional(),
}),
});
export const collections = { news, pages };