mirror of
https://github.com/Xevion/undefined.behavio.rs.git
synced 2025-12-06 09:16:53 -06:00
Display draft posts in development mode only
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import { getCollection } from "astro:content";
|
||||
import General from "@layouts/General.astro";
|
||||
import Summary from "@components/Summary.astro";
|
||||
const posts = (await getCollection("blog")).filter(entry => !entry.data.draft);
|
||||
const posts = (await getCollection("blog")).filter(entry => import.meta.env.DEV || !entry.data.draft);
|
||||
posts.sort((a, b) => new Date(b.data.pubDate).getTime() - new Date(a.data.pubDate).getTime());
|
||||
---
|
||||
|
||||
|
||||
@@ -3,11 +3,10 @@ import Post from "@layouts/Post.astro";
|
||||
import { getCollection } from "astro:content";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const blogEntries = await getCollection("blog");
|
||||
return blogEntries
|
||||
.filter((entry) => !entry.data.draft)
|
||||
const posts = await getCollection("blog");
|
||||
return posts
|
||||
.filter((entry) => import.meta.env.DEV || !entry.data.draft)
|
||||
.map((entry) => {
|
||||
console.log(entry.data.title);
|
||||
return {
|
||||
params: { slug: entry.slug },
|
||||
props: { entry },
|
||||
|
||||
@@ -1,15 +1,21 @@
|
||||
---
|
||||
import General from '@layouts/General.astro';
|
||||
import { getCollection } from 'astro:content';
|
||||
import General from "@layouts/General.astro";
|
||||
import { getCollection } from "astro:content";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const blogEntries = await getCollection('blog');
|
||||
const tags = new Set(blogEntries.filter(entry => !entry.data.draft).map(entry => entry.data.tags).flat());
|
||||
return Array.from(tags, (tag) => ({ params: {slug: tag}, props: {tag}}));
|
||||
const blogEntries = await getCollection("blog");
|
||||
const tags = new Set(
|
||||
blogEntries
|
||||
.filter((entry) => import.meta.env.DEV || !entry.data.draft)
|
||||
.map((entry) => entry.data.tags)
|
||||
.flat(),
|
||||
);
|
||||
return Array.from(tags, (tag) => ({ params: { slug: tag }, props: { tag } }));
|
||||
}
|
||||
|
||||
const { tag } = Astro.props;
|
||||
---
|
||||
|
||||
<General title={`${tag} posts`}>
|
||||
{ tag }
|
||||
{tag}
|
||||
</General>
|
||||
Reference in New Issue
Block a user