From e4ee3d570d7babd352cf9d06cc217199e0308b3d Mon Sep 17 00:00:00 2001 From: alberto Date: Thu, 19 Jun 2025 11:31:27 +0200 Subject: [PATCH] Conditionally hide and show post. When the user has no post, post in first pages are not shown and the posts page is hidden from the navbar. --- src/layouts/Base.astro | 8 ++++++++ src/pages/index.astro | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/src/layouts/Base.astro b/src/layouts/Base.astro index 1903fbc..050486f 100644 --- a/src/layouts/Base.astro +++ b/src/layouts/Base.astro @@ -1,4 +1,5 @@ --- + import config from '@/config' import Link from '@/components/Link.astro' import 'katex/dist/katex.min.css' @@ -12,6 +13,10 @@ import '@/themes/modern.css' // import '@/themes/colorful.css' // import '@/themes/mono.css' // import '@/themes/sober.css' + + +const posts = import.meta.glob>('../pages/posts/*.md', { eager: true }) + --- @@ -79,7 +84,10 @@ import '@/themes/modern.css' diff --git a/src/pages/index.astro b/src/pages/index.astro index bc7e5bb..83bc256 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -17,7 +17,10 @@ const posts = import.meta.glob>('./posts/*.md' articoli su vari argomenti, appunti di studio e molto altro.

+
+ { (Object.values(posts) != undefined && Object.values(posts).length != 0) ? (

Post Recenti

+
{ Object.values(posts) @@ -39,5 +42,8 @@ const posts = import.meta.glob>('./posts/*.md' )) }
+ + ) : (<>) + }