diff --git a/src/components/shortcodes/Spoiler.astro b/src/components/shortcodes/Spoiler.astro index 319f3f6..48b985d 100644 --- a/src/components/shortcodes/Spoiler.astro +++ b/src/components/shortcodes/Spoiler.astro @@ -1,9 +1,17 @@ --- const { tip = '' } = Astro.props +let divNeeded = false +const content = await Astro.slots.render('default') +if (content.includes('

')) { + divNeeded = true +} + --- - - - +{divNeeded ? +

+ : + +} \ No newline at end of file diff --git a/src/pages/categories/[...category].astro b/src/pages/categories/[...category].astro index c1c1b13..3b3a3d4 100644 --- a/src/pages/categories/[...category].astro +++ b/src/pages/categories/[...category].astro @@ -4,7 +4,9 @@ import {getCollection} from "astro:content"; import ArticleList from "../../components/ArticleList.astro"; export async function getStaticPaths() { - const allPosts = await getCollection('posts'); + const allPosts = await getCollection('posts', ({ data }) => { + return import.meta.env.PROD ? data.draft !== true : true; +}); // Get all categories, ensuring the default 'uncategorized' is used when categories is undefined const uniqueCategories = [...new Set(allPosts.map((post: any) => post.data.categories || ['uncategorized']).flat())]; diff --git a/src/pages/index.astro b/src/pages/index.astro index c04253a..7d80dd8 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -12,7 +12,7 @@ try { } --- - +

~/

{HomePageContent ? : diff --git a/src/pages/search-index.json.js b/src/pages/search-index.json.js index 8686b3b..65da20b 100644 --- a/src/pages/search-index.json.js +++ b/src/pages/search-index.json.js @@ -1,7 +1,9 @@ import { getCollection } from 'astro:content'; export async function GET() { - const posts = await getCollection('posts'); + const posts = await getCollection('posts', ({ data }) => { + return import.meta.env.PROD ? data.draft !== true : true; +}); const searchIndex = posts.map(post => ({ title: post.data.title, description: post.data.description || '', diff --git a/src/pages/tags.astro b/src/pages/tags.astro index 340f690..468f271 100644 --- a/src/pages/tags.astro +++ b/src/pages/tags.astro @@ -1,17 +1,26 @@ --- import {getCollection} from "astro:content"; import Layout from "../layouts/Layout.astro"; -const allPosts = await getCollection('posts'); +const allPosts = await getCollection('posts', ({ data }) => { + return import.meta.env.PROD ? data.draft !== true : true; +}); const uniqueTags = [...new Set(allPosts.map((post: any) => post.data.tags ? post.data.tags : []).flat())]; ---

~/blog/tags

- ls -l tags/ -
+ ls tags/ +
{uniqueTags.map((tag) => (

{tag}

))}
+ diff --git a/src/pages/tags/[...tag].astro b/src/pages/tags/[...tag].astro index 3b74126..865a49a 100644 --- a/src/pages/tags/[...tag].astro +++ b/src/pages/tags/[...tag].astro @@ -4,7 +4,9 @@ import {getCollection} from "astro:content"; import ArticleList from "../../components/ArticleList.astro"; export async function getStaticPaths() { - const allPosts = await getCollection('posts'); + const allPosts = await getCollection('posts', ({ data }) => { + return import.meta.env.PROD ? data.draft !== true : true; +}); const uniqueTags = [...new Set(allPosts.map((post: any) => post.data.tags ? post.data.tags : []).flat())]; return uniqueTags.map((tag) => { const filteredPosts = allPosts.filter((post: any) => post.data.tags?.includes(tag)); diff --git a/src/pages/twtxt.txt.js b/src/pages/twtxt.txt.js index 6af2c49..9311550 100644 --- a/src/pages/twtxt.txt.js +++ b/src/pages/twtxt.txt.js @@ -1,7 +1,9 @@ import { getCollection } from 'astro:content'; export async function GET(context) { - const posts = await getCollection('posts'); + const posts = await getCollection('posts', ({ data }) => { + return import.meta.env.PROD ? data.draft !== true : true; +}); // Sort posts by date (newest first) posts.sort((a, b) => new Date(b.data.date).getTime() - new Date(a.data.date).getTime()); diff --git a/src/plugins/heatmapdata/local.js b/src/plugins/heatmapdata/local.js index 0c04586..470a3c7 100644 --- a/src/plugins/heatmapdata/local.js +++ b/src/plugins/heatmapdata/local.js @@ -1,7 +1,9 @@ import { getCollection, render } from 'astro:content'; async function fetchPostsData() { - const posts = await getCollection('posts'); + const posts = await getCollection('posts', ({ data }) => { + return import.meta.env.PROD ? data.draft !== true : true; +}); const entriesData = {}; for (const post of posts) {