feat: hide nav item if no content in relevant collection
All checks were successful
Docker / build-and-push-image (push) Successful in 3m1s

This commit is contained in:
Troy 2025-08-22 22:57:31 +01:00
parent d1990ffb0e
commit e8160ad4fe
Signed by: troy
GPG key ID: DFC06C02ED3B4711
6 changed files with 29 additions and 21 deletions

View file

@ -2,9 +2,30 @@
import { SITE } from "@consts";
import Button from "@components/Button.astro";
import { Icon } from "astro-icon/components";
import { getCollection } from "astro:content";
const pathname = new URL(Astro.request.url).pathname;
const currentPath = pathname.replace(/\/$/, "");
const allPosts = (await getCollection("posts")).filter(
(post) => !post.data.draft,
);
const hasPosts = allPosts.length > 0;
const allProjects = (await getCollection("projects")).filter(
(post) => !post.data.draft,
);
const hasProjects = allProjects.length > 0;
const filteredNavLinks = SITE.NAVLINKS.filter((link) => {
if (link.href === "/posts") {
return hasPosts;
}
if (link.href === "/projects") {
return hasProjects;
}
return true;
});
---
<header class="mx-auto w-full">
@ -17,9 +38,10 @@ const currentPath = pathname.replace(/\/$/, "");
</a>
<ul class="flex w-fit flex-row items-center gap-4">
{
SITE.NAVLINKS.map((link) => {
filteredNavLinks.map((link) => {
let linkHref = link.href.replace(/\/$/, "");
const isActive = currentPath.startsWith(linkHref);
return (
<li class="text-tertiary hover:text-secondary focus:text-secondary font-medium transition-colors duration-300 focus:outline-hidden">
<a

View file

@ -8,6 +8,7 @@ image:
alt: "Flashing the chips"
categories: ["personal"]
tags: ["linux", "libreboot", "raspberry pi", "thinkpad", "x230"]
draft: true
---
This post is a simple guide on how I "Librebooted" my Lenovo Thinkpad X230. I struggled to find instructions which detailed the entire process for a beginner who has never used tools such as flashrom before. The examples I have given here are based on what I did personally. Whilst these are the exact steps I took, for you there may be other or completely different steps so please reference the [documentation](https://libreboot.org/docs/install/x230_external.html) before carrying out any steps listed here.

View file

@ -29,6 +29,9 @@ _**Night** This was the original vision for the piece before pivoting towards th
![Alan Wake II reference PureRef board](reference.jpg)
_**Reference board** A small collection of related in-game imagery used as inspiration for both explored lighting approaches._
![Alan Wake II Blender viewport](viewport.jpg)
_**Viewport** View of the scene within Blender with heavily instanced assets being hidden such as the floor mulch or trees._
### Early progress and tests
<Gallery

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 KiB

View file

@ -16,17 +16,6 @@ const posts = (await getCollection("posts"))
<ol
class="animate-reveal grid grid-cols-1 gap-6 opacity-0 [animation-delay:0.1s]"
>
{
//import type { CollectionEntry } from "astro:content";
//posts.map((article: CollectionEntry<"posts">) => (
posts.map((article: any) => <ShowcasePost collection={article} />)
}
{posts.map((article) => <ShowcasePost collection={article} />)}
</ol>
<div class="animate-reveal flex justify-end opacity-0 [animation-delay:0.2s]">
<a
href="/posts.xml"
class="text-tertiary hover:text-secondary text-xs transition-colors duration-300"
>View posts feed</a
>
</div>
</Layout>

View file

@ -21,13 +21,6 @@ const projects = (await getCollection("projects"))
<ol
class="animate-reveal grid grid-cols-1 gap-4 opacity-0 [animation-delay:0.1s] md:grid-cols-2"
>
{projects.map((article: any) => <ShowcaseProject collection={article} />)}
{projects.map((article) => <ShowcaseProject collection={article} />)}
</ol>
<div class="animate-reveal flex justify-end opacity-0 [animation-delay:0.2s]">
<a
href="/projects.xml"
class="text-tertiary hover:text-secondary text-xs transition-colors duration-300"
>View projects feed</a
>
</div>
</Layout>