Rename blog collection as posts

This commit is contained in:
prototypa
2023-01-21 21:37:09 -05:00
parent b3dd2b5505
commit b1c6c91989
8 changed files with 12 additions and 6 deletions

View File

@ -1,6 +1,6 @@
import { z, defineCollection } from 'astro:content'; import { z, defineCollection } from 'astro:content';
const blog = defineCollection({ const posts = defineCollection({
schema: z.object({ schema: z.object({
title: z.string(), title: z.string(),
description: z.string().optional(), description: z.string().optional(),
@ -23,5 +23,5 @@ const blog = defineCollection({
}); });
export const collections = { export const collections = {
blog: blog, posts: posts,
}; };

View File

@ -102,7 +102,6 @@ const meta = {
<Content <Content
highlight="Inside template" highlight="Inside template"
title="And what's inside? ..." title="And what's inside? ..."
content="Ne dicta praesent ocurreret has, diam theophrastus at pro. Eos etiam regione ut, persius eripuit quo id. Sit te euismod tacimates."
items={[ items={[
{ {
title: 'Per ei quaeque sensibus', title: 'Per ei quaeque sensibus',
@ -124,7 +123,14 @@ const meta = {
src: import('~/assets/images/caos.jpg'), src: import('~/assets/images/caos.jpg'),
alt: 'Colorful Image', alt: 'Colorful Image',
}} }}
/> >
<Fragment slot="content">
<h3 class="text-2xl font-bold tracking-tight text-gray-900 dark:text-white sm:text-3xl mb-2">
Ad vix debet docendi
</h3>
Ne dicta praesent ocurreret has, diam theophrastus at pro. Eos etiam regione ut, persius eripuit quo id. Sit te euismod tacimates.
</Fragment>
</Content>
<!-- Content Widget **************** --> <!-- Content Widget **************** -->

View File

@ -3,7 +3,7 @@ import type { CollectionEntry } from 'astro:content';
import type { Post } from '~/types'; import type { Post } from '~/types';
import { cleanSlug } from './permalinks'; import { cleanSlug } from './permalinks';
const getNormalizedPost = async (post: CollectionEntry<'blog'>): Promise<Post> => { const getNormalizedPost = async (post: CollectionEntry<'posts'>): Promise<Post> => {
const { id, slug = '', data } = post; const { id, slug = '', data } = post;
const { Content, remarkPluginFrontmatter } = await post.render(); const { Content, remarkPluginFrontmatter } = await post.render();
@ -28,7 +28,7 @@ const getNormalizedPost = async (post: CollectionEntry<'blog'>): Promise<Post> =
}; };
const load = async function (): Promise<Array<Post>> { const load = async function (): Promise<Array<Post>> {
const posts = await getCollection('blog'); const posts = await getCollection('posts');
const normalizedPosts = posts.map(async (post) => await getNormalizedPost(post)); const normalizedPosts = posts.map(async (post) => await getNormalizedPost(post));
const results = (await Promise.all(normalizedPosts)) const results = (await Promise.all(normalizedPosts))