- Added Czech translation of the first blog post - Finishing touches and details - Translaitions of composition names - Changing naming scheme in content/music/
66 lines
1.5 KiB
JavaScript
66 lines
1.5 KiB
JavaScript
// 1. Import utilities from `astro:content`
|
|
import { z, defineCollection, getCollection } from 'astro:content';
|
|
// 2. Define your collection(s)
|
|
const blogCollection = defineCollection({
|
|
type: "content",
|
|
schema: z.object({
|
|
title: z.string(),
|
|
description: z.string(),
|
|
author: z.string().default("Anonymous"),
|
|
publishDate: z.date(),
|
|
image: z.object({
|
|
url: z.string(),
|
|
alt: z.string()
|
|
}),
|
|
language: z.enum(['en', 'cs', 'de', 'fr']),
|
|
tags: z.array(z.string()).optional()
|
|
})
|
|
});
|
|
|
|
const musicCollection = defineCollection({
|
|
type: "content",
|
|
schema: z.object({
|
|
name: z.object({
|
|
en: z.string(),
|
|
de: z.string(),
|
|
fr: z.string(),
|
|
cs: z.string()
|
|
}),
|
|
comment: z.object({
|
|
en: z.string(),
|
|
de: z.string(),
|
|
cs: z.string(),
|
|
fr: z.string()
|
|
}),
|
|
publishDate: z.date(),
|
|
image: z.object({
|
|
url: z.string(),
|
|
alt: z.string()
|
|
}),
|
|
pdfLink: z.string().optional(),
|
|
flacLink: z.string().optional(),
|
|
mp3Link: z.string()
|
|
})
|
|
});
|
|
// 3. Export a single `collections` object to register your collection(s)
|
|
// This key should match your collection directory name in "src/content"
|
|
export const collections = {
|
|
'blog': blogCollection,
|
|
'music': musicCollection
|
|
};
|
|
|
|
export async function getBlogPosts() {
|
|
const posts = await getCollection('blog');
|
|
|
|
return posts.map((post) => {
|
|
const blog_slug = post.slug.split('/')[0];
|
|
return {
|
|
...post,
|
|
blog_slug
|
|
}
|
|
})
|
|
}
|
|
|
|
export async function getCompositions() {
|
|
return await getCollection('music');
|
|
} |