mirror of
https://github.com/maciejpedzich/maciejpedzi.ch.git
synced 2024-11-27 23:55:47 +01:00
Add draft field to each post
This commit is contained in:
parent
8af70859e3
commit
a1e0c32d02
@ -22,6 +22,11 @@
|
||||
"default": "{{now}}",
|
||||
"isPublishDate": true
|
||||
},
|
||||
{
|
||||
"title": "Draft",
|
||||
"name": "draft",
|
||||
"type": "draft"
|
||||
},
|
||||
{
|
||||
"title": "Categories",
|
||||
"name": "categories",
|
||||
|
@ -7,6 +7,7 @@ categories:
|
||||
tags:
|
||||
- vue
|
||||
- nuxt
|
||||
draft: false
|
||||
---
|
||||
|
||||
## Introduction
|
||||
|
@ -4,6 +4,7 @@ const blog = defineCollection({
|
||||
schema: z.object({
|
||||
title: z.string(),
|
||||
description: z.string(),
|
||||
draft: z.boolean(),
|
||||
pubDate: z
|
||||
.string()
|
||||
.or(z.date())
|
||||
|
@ -1,44 +1,32 @@
|
||||
---
|
||||
import { getCollection } from 'astro:content';
|
||||
import BaseLayout from '../../layouts/BaseLayout.astro';
|
||||
|
||||
import BaseHead from '../../components/BaseHead.astro';
|
||||
import Header from '../../components/Header.astro';
|
||||
import Footer from '../../components/Footer.astro';
|
||||
|
||||
const posts = (await getCollection('blog')).sort(
|
||||
const posts = (await getCollection('blog', (entry) => !entry.data.draft)).sort(
|
||||
(a, b) => a.data.pubDate.valueOf() - b.data.pubDate.valueOf()
|
||||
);
|
||||
---
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<BaseHead
|
||||
title="blog"
|
||||
description="blog about the making of maciej's projects and more"
|
||||
/>
|
||||
<style>
|
||||
section {
|
||||
text-align: center;
|
||||
<BaseLayout
|
||||
title="blog"
|
||||
description="blog about the making of maciej's projects and more"
|
||||
>
|
||||
<section>
|
||||
<h2>My blog</h2>
|
||||
<ul class="post-list">
|
||||
{
|
||||
posts.map((post) => (
|
||||
<li>
|
||||
<a href={`/blog/${post.slug}/`}>{post.data.title}</a>
|
||||
</li>
|
||||
))
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<Header />
|
||||
<main>
|
||||
<section>
|
||||
<h2>My blog</h2>
|
||||
<ul class="post-list">
|
||||
{
|
||||
posts.map((post) => (
|
||||
<li>
|
||||
<a href={`/blog/${post.slug}/`}>{post.data.title}</a>
|
||||
</li>
|
||||
))
|
||||
}
|
||||
</ul>
|
||||
</section>
|
||||
</main>
|
||||
<Footer />
|
||||
</body>
|
||||
</html>
|
||||
</ul>
|
||||
</section>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
section {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
Loading…
Reference in New Issue
Block a user