Skip to content

Commit 0960224

Browse files
committed
update header
1 parent 53144ba commit 0960224

File tree

3 files changed

+51
-10
lines changed

3 files changed

+51
-10
lines changed

.github/workflows/deploy.yml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,27 @@ jobs:
2222
- name: Checkout
2323
uses: actions/checkout@v4
2424

25+
- name: Setup Node
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: '18'
29+
cache: 'npm'
30+
2531
- name: Setup Pages
2632
uses: actions/configure-pages@v4
27-
33+
34+
- name: Install dependencies
35+
run: npm ci
36+
2837
- name: Build with Astro
29-
uses: withastro/action@v2
38+
run: |
39+
npm run build
40+
41+
- name: Upload artifact
42+
uses: actions/upload-pages-artifact@v2
3043
with:
31-
path: .
32-
node-version: 18
33-
package-manager: npm
34-
44+
path: ./dist
45+
3546
deploy:
3647
environment:
3748
name: github-pages
@@ -41,4 +52,4 @@ jobs:
4152
steps:
4253
- name: Deploy to GitHub Pages
4354
id: deployment
44-
uses: actions/deploy-pages@v4
55+
uses: actions/deploy-pages@v3

astro.config.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { defineConfig, passthroughImageService } from "astro/config";
66
// https://astro.build/config
77
export default defineConfig({
88
site: "https://recursivezero.com",
9+
base: "/",
910
devToolbar: {
1011
enabled: false
1112
},
@@ -28,7 +29,8 @@ export default defineConfig({
2829
//adapter: node({ mode: "standalone" }),
2930
output: "static",
3031
build: {
31-
format: "directory"
32+
format: "directory",
33+
assets: "assets"
3234
},
3335
prefetch: {
3436
prefetchAll: true

src/components/Header.astro

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,35 @@
11
---
22
import { Picture } from "astro:assets";
33
import logoImage from "/public/assets/images/RecursiveZero-White.jpg";
4+
const currentPath = Astro.url.pathname;
5+
const base = import.meta.env.BASE_URL;
6+
7+
// Helper function to normalize paths for comparison
8+
const normalizePath = (path: string) => {
9+
return path.endsWith("/") && path !== "/" ? path.slice(0, -1) : path;
10+
};
11+
12+
// Helper function to check if a link is active
13+
const isActive = (linkPath: string) => {
14+
const normalizedCurrent = normalizePath(currentPath);
15+
const normalizedLink = normalizePath(linkPath);
16+
17+
if (linkPath === base) {
18+
// Home page - exact match
19+
return normalizedCurrent === normalizedLink || normalizedCurrent === base.slice(0, -1);
20+
}
21+
22+
// Other pages - check if current path starts with link path
23+
return normalizedCurrent.startsWith(normalizedLink);
24+
};
425
---
526

627
<header>
728
<div class="nav-container w-full">
829
<nav class="">
930
<div class="mx-5 flex w-full items-center justify-between">
1031
<h1 class="text-[1.05rem] font-bold leading-[-0.03em] lg:text-[1.2rem]">
11-
<a href="/" class="flex items-center gap-[0.5rem] lg:flex-row">
32+
<a href={base} class="flex items-center gap-[0.5rem] lg:flex-row">
1233
<Picture
1334
src={logoImage}
1435
formats={["png", "jpeg", "jpg", "webp"]}
@@ -25,7 +46,14 @@ import logoImage from "/public/assets/images/RecursiveZero-White.jpg";
2546
</h1>
2647
<ul class="menu-list flex items-center gap-[1.5rem] lg:flex-row-reverse">
2748
<!--<li id="themeToggle">
28-
<button class="sunBtn">
49+
<button class="sunBtn">const currentPath = Astro.url.pathname;
50+
const base = import.meta.env.BASE_URL || '/';
51+
52+
// Helper function to create correct paths
53+
const createPath = (path: string) => {
54+
if (path === '/') return base;
55+
return `${base}${path}`.replace(/\/+/g, '/');
56+
};
2957
<i class="fa fa-sun-o" aria-hidden="true">Light</i>
3058
</button>
3159
<button class="moonBtn hidden">

0 commit comments

Comments
 (0)