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}}",
|
"default": "{{now}}",
|
||||||
"isPublishDate": true
|
"isPublishDate": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"title": "Draft",
|
||||||
|
"name": "draft",
|
||||||
|
"type": "draft"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"title": "Categories",
|
"title": "Categories",
|
||||||
"name": "categories",
|
"name": "categories",
|
||||||
|
@ -7,6 +7,7 @@ categories:
|
|||||||
tags:
|
tags:
|
||||||
- vue
|
- vue
|
||||||
- nuxt
|
- nuxt
|
||||||
|
draft: false
|
||||||
---
|
---
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
@ -4,6 +4,7 @@ const blog = defineCollection({
|
|||||||
schema: z.object({
|
schema: z.object({
|
||||||
title: z.string(),
|
title: z.string(),
|
||||||
description: z.string(),
|
description: z.string(),
|
||||||
|
draft: z.boolean(),
|
||||||
pubDate: z
|
pubDate: z
|
||||||
.string()
|
.string()
|
||||||
.or(z.date())
|
.or(z.date())
|
||||||
|
@ -1,44 +1,32 @@
|
|||||||
---
|
---
|
||||||
import { getCollection } from 'astro:content';
|
import { getCollection } from 'astro:content';
|
||||||
|
import BaseLayout from '../../layouts/BaseLayout.astro';
|
||||||
|
|
||||||
import BaseHead from '../../components/BaseHead.astro';
|
const posts = (await getCollection('blog', (entry) => !entry.data.draft)).sort(
|
||||||
import Header from '../../components/Header.astro';
|
|
||||||
import Footer from '../../components/Footer.astro';
|
|
||||||
|
|
||||||
const posts = (await getCollection('blog')).sort(
|
|
||||||
(a, b) => a.data.pubDate.valueOf() - b.data.pubDate.valueOf()
|
(a, b) => a.data.pubDate.valueOf() - b.data.pubDate.valueOf()
|
||||||
);
|
);
|
||||||
---
|
---
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<BaseLayout
|
||||||
<html lang="en">
|
title="blog"
|
||||||
<head>
|
description="blog about the making of maciej's projects and more"
|
||||||
<BaseHead
|
>
|
||||||
title="blog"
|
<section>
|
||||||
description="blog about the making of maciej's projects and more"
|
<h2>My blog</h2>
|
||||||
/>
|
<ul class="post-list">
|
||||||
<style>
|
{
|
||||||
section {
|
posts.map((post) => (
|
||||||
text-align: center;
|
<li>
|
||||||
|
<a href={`/blog/${post.slug}/`}>{post.data.title}</a>
|
||||||
|
</li>
|
||||||
|
))
|
||||||
}
|
}
|
||||||
</style>
|
</ul>
|
||||||
</head>
|
</section>
|
||||||
<body>
|
</BaseLayout>
|
||||||
<Header />
|
|
||||||
<main>
|
<style>
|
||||||
<section>
|
section {
|
||||||
<h2>My blog</h2>
|
text-align: center;
|
||||||
<ul class="post-list">
|
}
|
||||||
{
|
</style>
|
||||||
posts.map((post) => (
|
|
||||||
<li>
|
|
||||||
<a href={`/blog/${post.slug}/`}>{post.data.title}</a>
|
|
||||||
</li>
|
|
||||||
))
|
|
||||||
}
|
|
||||||
</ul>
|
|
||||||
</section>
|
|
||||||
</main>
|
|
||||||
<Footer />
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
Loading…
Reference in New Issue
Block a user