diff --git a/app/[locale]/blog/[slug]/page.tsx b/app/[locale]/blog/[slug]/page.tsx index 6c885dfb..a7be5101 100644 --- a/app/[locale]/blog/[slug]/page.tsx +++ b/app/[locale]/blog/[slug]/page.tsx @@ -69,6 +69,11 @@ export default async function BlogPost({ params }: BlogPostProps) { category={post.frontmatter.category} readingTime={getReadingTime(post.content)} /> + {(new Date(post.frontmatter.date) > new Date() || post.frontmatter.public === false) && ( +
+ Preview (Not visible in production) +
+ )} {/* Featured Image Header */} {post.frontmatter.featuredImage ? (
diff --git a/app/[locale]/blog/page.tsx b/app/[locale]/blog/page.tsx index eaf9a659..75813546 100644 --- a/app/[locale]/blog/page.tsx +++ b/app/[locale]/blog/page.tsx @@ -75,9 +75,16 @@ export default async function BlogIndex({ params }: BlogIndexProps) {
- - {t('featuredPost')} - +
+ {t('featuredPost')} + {featuredPost && + (new Date(featuredPost.frontmatter.date) > new Date() || + featuredPost.frontmatter.public === false) && ( + + Preview + + )} +
{featuredPost && ( <> @@ -168,6 +175,15 @@ export default async function BlogIndex({ params }: BlogIndexProps) { {post.frontmatter.category} )} + {(new Date(post.frontmatter.date) > new Date() || + post.frontmatter.public === false) && ( + + Preview + + )}
)}
diff --git a/data/blog/de/johannes-gleich-startet-als-senior-key-account-manager-durch.mdx b/data/blog/de/johannes-gleich-startet-als-senior-key-account-manager-durch.mdx index a2932a29..ac2d2a1a 100644 --- a/data/blog/de/johannes-gleich-startet-als-senior-key-account-manager-durch.mdx +++ b/data/blog/de/johannes-gleich-startet-als-senior-key-account-manager-durch.mdx @@ -5,6 +5,7 @@ featuredImage: /uploads/2026/01/1767353529807.jpg locale: de category: Kabel Technologie excerpt: 'KLZ Cables startet mit einer starken Verstärkung ins neue Jahr: Johannes Gleich übernimmt die Rolle des Senior Key Account Managers. Erfahren Sie mehr über unseren neuen Experten für Infrastruktur und Energieversorger.' +public: false --- # Herzlich willkommen bei KLZ: Johannes Gleich startet als Senior Key Account Manager durch diff --git a/data/blog/en/johannes-gleich-starts-as-senior-key-account-manager.mdx b/data/blog/en/johannes-gleich-starts-as-senior-key-account-manager.mdx index a0d7fe1a..972279cc 100644 --- a/data/blog/en/johannes-gleich-starts-as-senior-key-account-manager.mdx +++ b/data/blog/en/johannes-gleich-starts-as-senior-key-account-manager.mdx @@ -5,6 +5,7 @@ featuredImage: /uploads/2026/01/1767353529807.jpg locale: en category: Cable Technology excerpt: 'KLZ Cables kicks off the new year with a strong addition: Johannes Gleich takes on the role of Senior Key Account Manager. Learn more about our new expert for infrastructure and energy suppliers.' +public: false --- # Welcome to KLZ: Johannes Gleich starts as Senior Key Account Manager diff --git a/lib/blog.ts b/lib/blog.ts index 85769873..8ec1e8c6 100644 --- a/lib/blog.ts +++ b/lib/blog.ts @@ -2,6 +2,7 @@ import fs from 'fs'; import path from 'path'; import matter from 'gray-matter'; import { mapSlugToFileSlug } from './slugs'; +import { config } from '@/lib/config'; export interface PostFrontmatter { title: string; @@ -10,6 +11,7 @@ export interface PostFrontmatter { featuredImage?: string | null; category?: string; locale: string; + public?: boolean; } export interface PostMdx { @@ -18,6 +20,17 @@ export interface PostMdx { content: string; } +export function isPostVisible(post: { frontmatter: { date: string; public?: boolean } }) { + // If explicitly marked as not public, hide in production + if (post.frontmatter.public === false && config.isProduction) { + return false; + } + + const postDate = new Date(post.frontmatter.date); + const now = new Date(); + return !(postDate > now && config.isProduction); +} + export async function getPostBySlug(slug: string, locale: string): Promise { // Map translated slug to file slug const fileSlug = await mapSlugToFileSlug(slug, locale); @@ -31,11 +44,17 @@ export async function getPostBySlug(slug: string, locale: string): Promise { @@ -55,6 +74,7 @@ export async function getAllPosts(locale: string): Promise { content, }; }) + .filter(isPostVisible) .sort( (a, b) => new Date(b.frontmatter.date).getTime() - new Date(a.frontmatter.date).getTime(), ); @@ -78,6 +98,7 @@ export async function getAllPostsMetadata(locale: string): Promise new Date(b.frontmatter.date as string).getTime() -