mirror of
https://github.com/Xevion/undefined.behavio.rs.git
synced 2025-12-06 17: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 { getCollection } from "astro:content";
|
||||||
import General from "@layouts/General.astro";
|
import General from "@layouts/General.astro";
|
||||||
import Summary from "@components/Summary.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());
|
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";
|
import { getCollection } from "astro:content";
|
||||||
|
|
||||||
export async function getStaticPaths() {
|
export async function getStaticPaths() {
|
||||||
const blogEntries = await getCollection("blog");
|
const posts = await getCollection("blog");
|
||||||
return blogEntries
|
return posts
|
||||||
.filter((entry) => !entry.data.draft)
|
.filter((entry) => import.meta.env.DEV || !entry.data.draft)
|
||||||
.map((entry) => {
|
.map((entry) => {
|
||||||
console.log(entry.data.title);
|
|
||||||
return {
|
return {
|
||||||
params: { slug: entry.slug },
|
params: { slug: entry.slug },
|
||||||
props: { entry },
|
props: { entry },
|
||||||
|
|||||||
@@ -1,15 +1,21 @@
|
|||||||
---
|
---
|
||||||
import General from '@layouts/General.astro';
|
import General from "@layouts/General.astro";
|
||||||
import { getCollection } from 'astro:content';
|
import { getCollection } from "astro:content";
|
||||||
|
|
||||||
export async function getStaticPaths() {
|
export async function getStaticPaths() {
|
||||||
const blogEntries = await getCollection('blog');
|
const blogEntries = await getCollection("blog");
|
||||||
const tags = new Set(blogEntries.filter(entry => !entry.data.draft).map(entry => entry.data.tags).flat());
|
const tags = new Set(
|
||||||
return Array.from(tags, (tag) => ({ params: {slug: tag}, props: {tag}}));
|
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;
|
const { tag } = Astro.props;
|
||||||
---
|
---
|
||||||
|
|
||||||
<General title={`${tag} posts`}>
|
<General title={`${tag} posts`}>
|
||||||
{ tag }
|
{tag}
|
||||||
</General>
|
</General>
|
||||||
|
|||||||
Reference in New Issue
Block a user