extract post-listing logic
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
---
|
||||
import '@styles/prose.css';
|
||||
|
||||
import { getCollection, render } from 'astro:content';
|
||||
import { render } from 'astro:content';
|
||||
import { listPosts } from '@lib/content.ts';
|
||||
import BaseLayout from '@layouts/BaseLayout.astro';
|
||||
|
||||
// return all posts in dev, only non-draft in prod
|
||||
let entries = await getCollection('posts', ({ data }) => !data.draft || import.meta.env.DEV );
|
||||
entries.sort((a, b) => b.data.date.getTime() - a.data.date.getTime());
|
||||
const entries = await listPosts();
|
||||
const posts = await Promise.all(entries.map(async entry => {
|
||||
const { remarkPluginFrontmatter } = await render(entry);
|
||||
return { ...entry, remarkPluginFrontmatter };
|
||||
|
||||
Reference in New Issue
Block a user