filter out drafts

This commit is contained in:
Daniel Bulant 2025-03-29 20:17:28 +01:00
parent ac48e64e66
commit d3afae6faf
No known key found for this signature in database
4 changed files with 18 additions and 38 deletions

View file

@ -50,5 +50,6 @@
"unist-util-visit": "^4.1.2",
"vite": "^4.1.4",
"xterm": "4.18.0"
}
},
"packageManager": "pnpm@9.5.0+sha1.8c155dc114e1689d18937974f6571e0ceee66f1d"
}

View file

@ -4,7 +4,7 @@
export async function GET(req) {
const allPostFiles = import.meta.glob('../../posts/**/*.md');
const allPosts = await Promise.all(
const allPosts = (await Promise.all(
Object.entries(allPostFiles).map(async ([path, resolver]) => {
const { metadata } = await resolver();
let postPath = path.slice(2, -3);
@ -14,7 +14,7 @@ export async function GET(req) {
path: postPath,
};
})
);
)).filter(t => !t.draft);
allPosts.sort((a, b) => {
return new Date(b.date) - new Date(a.date)

View file

@ -41,23 +41,17 @@
<div class="parent md:flex max-w-screen">
<h1 class="md:hidden">Posts</h1>
{#if tags}
<div class="tags md:flex-col">
{#each tags as tag}
<div class="tag" class:selected={selectedTags.includes(tag)} on:click={() => toggle(tag)} on:keydown={() => toggle(tag)}>
{tag}
</div>
{/each}
<a href="/posts/rss.xml" class="rss hidden flex items-center w-full md:block">
<img src="/rss-icon.svg" alt="RSS icon" class="w-6 h-6 inline" />
RSS
</a>
</div>
{/if}
<div class="posts">
<h1 class="hidden md:block">Posts</h1>
<h1 class="hidden md:block">
Posts
<small>
<a href="/posts/rss.xml" class="rss">
<img src="/rss-icon.svg" alt="RSS icon" />
RSS
</a>
</small>
</h1>
{#if !selectedTags.length || selectedTags.find(tag => posts[0].categories.includes(tag))}
<HeroPost {...posts[0]} />
@ -71,8 +65,6 @@
<Post {...post} bind:currentHover />
</div>
{/each}
<small class="md:hidden block">There's also RSS feed available <a href="/posts/rss.xml">here</a>.</small>
</div>
</div>
@ -88,23 +80,6 @@
@apply w-2xl;
}
}
.tags {
@apply flex flex-wrap gap-2 mt-2 mb-3;
}
:global(.dark) .tag {
background: rgb(77, 77, 77);
}
.tag {
@apply rounded-full cursor-pointer select-none px-4 py-2;
background: rgb(173, 173, 173);
text-transform: capitalize;
}
:global(.dark) .tag.selected {
background: rgb(0, 108, 170);
}
.tag.selected {
background: rgb(0, 162, 255);
}
h1 {
@apply m-0 mb-1 p-0 font-bold text-3xl;
}
@ -125,6 +100,9 @@
color: rgb(4, 192, 192)
}
.rss {
@apply pl-4;
@apply pl-4 text-sm;
}
.rss img {
@apply inline mr-1 w-4 h-4;
}
</style>

View file

@ -5,6 +5,7 @@ author: Daniel Bulant
authorIcon: /logo.png
categories: [programming, homelab]
description: I had setuped my homelab quite a while ago, but I never wrote about it. So here it is.
draft: true
---
I had setuped my homelab quite a while ago, but I never wrote about it.