add content collection schemas
parent
4c1bcf02ed
commit
626d94694c
@ -1,11 +1,29 @@
|
|||||||
// 1. Import utilities from `astro:content`
|
// 1. Import utilities from `astro:content`
|
||||||
import { defineCollection } from "astro:content";
|
import { defineCollection, z } from "astro:content";
|
||||||
// 2. Define your collection(s)
|
// 2. Define your collection(s)
|
||||||
const blogCollection = defineCollection({
|
const journalCollection = defineCollection({
|
||||||
/* ... */
|
type: "content",
|
||||||
|
schema: z.object({
|
||||||
|
title: z.string(),
|
||||||
|
date: z.date(),
|
||||||
|
tags: z.string().array(),
|
||||||
|
category: z.string().optional(),
|
||||||
|
description: z.string().optional(),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
const articleCollection = defineCollection({
|
||||||
|
type: "content",
|
||||||
|
schema: z.object({
|
||||||
|
title: z.string(),
|
||||||
|
date: z.date(),
|
||||||
|
tags: z.string().array(),
|
||||||
|
category: z.string().optional(),
|
||||||
|
description: z.string().optional(),
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
// 3. Export a single `collections` object to register your collection(s)
|
// 3. Export a single `collections` object to register your collection(s)
|
||||||
// This key should match your collection directory name in "src/content"
|
// This key should match your collection directory name in "src/content"
|
||||||
export const collections = {
|
export const collections = {
|
||||||
blog: blogCollection,
|
"journal-entries": journalCollection,
|
||||||
|
articles: articleCollection,
|
||||||
};
|
};
|
||||||
|
@ -1,9 +1,30 @@
|
|||||||
---
|
---
|
||||||
import Layout from '../../layouts/Layout.astro';
|
import Layout from '../../layouts/Layout.astro';
|
||||||
|
import Section from 'fulldev-ui/components/Section.astro';
|
||||||
|
import { getCollection } from 'astro:content';
|
||||||
|
|
||||||
|
const articles = await getCollection('articles');
|
||||||
export const prerender = true;
|
export const prerender = true;
|
||||||
---
|
---
|
||||||
<Layout title="Articles">
|
<Layout title="Articles">
|
||||||
<main>
|
<main>
|
||||||
|
<Section
|
||||||
|
title="Articles"
|
||||||
|
text="Coming Soon!"
|
||||||
|
cards={articles.map((article)=>({
|
||||||
|
frame:"panel",
|
||||||
|
title:article.data.title,
|
||||||
|
tagline: article.data.date.toISOString().substring(0,10),
|
||||||
|
// list: ["one", "two"],
|
||||||
|
badge: article.data.category,
|
||||||
|
href: `/articles/${article.slug}`,
|
||||||
|
description: article.data.description,
|
||||||
|
}))}
|
||||||
|
|
||||||
|
align='center'
|
||||||
|
justify="start"
|
||||||
|
structure="grid"
|
||||||
|
>
|
||||||
|
</Section>
|
||||||
</main>
|
</main>
|
||||||
</Layout>
|
</Layout>
|
@ -1,9 +1,35 @@
|
|||||||
---
|
---
|
||||||
|
import { getCollection } from 'astro:content';
|
||||||
import Layout from '../../layouts/Layout.astro';
|
import Layout from '../../layouts/Layout.astro';
|
||||||
|
import Section from 'fulldev-ui/components/Section.astro';
|
||||||
|
import Text from 'fulldev-ui/components/Text.astro';
|
||||||
|
|
||||||
|
|
||||||
|
const journalEntries = await getCollection('journal-entries');
|
||||||
|
|
||||||
export const prerender = true;
|
export const prerender = true;
|
||||||
---
|
---
|
||||||
<Layout title="Journal Entries">
|
<Layout title="Journal Entries">
|
||||||
<main>
|
<main>
|
||||||
|
<Section
|
||||||
|
title="Journal Entries"
|
||||||
|
cards={journalEntries.map((journalEntry)=>({
|
||||||
|
frame:"panel",
|
||||||
|
title:journalEntry.data.title,
|
||||||
|
tagline: journalEntry.data.date.toISOString().substring(0,10),
|
||||||
|
badge: journalEntry.data.category,
|
||||||
|
// badges: journalEntry.data.tags,
|
||||||
|
href: `/journal/${journalEntry.slug}`,
|
||||||
|
description: journalEntry.data.description,
|
||||||
|
// html: <Text>{journalEntry.data.description}</Text>,
|
||||||
|
size: "sm",
|
||||||
|
}))}
|
||||||
|
|
||||||
|
align='center'
|
||||||
|
justify="start"
|
||||||
|
structure="grid"
|
||||||
|
size="md"
|
||||||
|
>
|
||||||
|
</Section>
|
||||||
</main>
|
</main>
|
||||||
</Layout>
|
</Layout>
|
@ -1,3 +1,6 @@
|
|||||||
{
|
{
|
||||||
"extends": "astro/tsconfigs/strict"
|
"extends": "astro/tsconfigs/strict",
|
||||||
|
"compilerOptions": {
|
||||||
|
"strictNullChecks": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
import { defineConfig } from "unocss";
|
import { defineConfig } from "unocss";
|
||||||
|
import presetUno from "@unocss/preset-uno";
|
||||||
import fulldevUI from "fulldev-ui/unocss";
|
import fulldevUI from "fulldev-ui/unocss";
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
injectReset: false,
|
injectReset: true,
|
||||||
|
presets: [
|
||||||
|
presetUno,
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
presets: [fulldevUI],
|
fulldevUI,
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue