From f1073b0bfd812183d8111556b71c14268ddc7d9e Mon Sep 17 00:00:00 2001 From: John Dunning Date: Sat, 13 Jan 2024 14:04:52 -0800 Subject: [PATCH] Add tag to fix URLs when hosted at a path Fix path handling in HeaderNav.astro. Fix titles on all pages. --- .github/workflows/deploy.yml | 2 +- packages/astro/astro.config.mjs | 2 +- packages/astro/src/components/HeaderNav.astro | 17 +++++++++-------- packages/astro/src/layouts/Page.astro | 1 + packages/astro/src/pages/about.astro | 2 +- packages/astro/src/pages/blog.astro | 4 ++-- packages/astro/src/pages/events.astro | 2 +- packages/astro/src/pages/getting-started.astro | 2 +- packages/astro/src/pages/projects.astro | 2 +- packages/astro/src/pages/wiki.astro | 2 +- 10 files changed, 19 insertions(+), 17 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2d9736a..285ff45 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -25,7 +25,7 @@ jobs: with: path: packages/astro # The root location of your Astro project inside the repository. (optional) # node-version: 18 # The specific version of Node that should be used to build your site. Defaults to 18. (optional) - package-manager: npm # The Node package manager that should be used to install dependencies and build your site. Automatically detected based on your lockfile. (optional) + package-manager: npm@latest # The Node package manager that should be used to install dependencies and build your site. Automatically detected based on your lockfile. (optional) deploy: needs: build diff --git a/packages/astro/astro.config.mjs b/packages/astro/astro.config.mjs index 3862157..f8826bd 100644 --- a/packages/astro/astro.config.mjs +++ b/packages/astro/astro.config.mjs @@ -3,6 +3,6 @@ import { defineConfig } from "astro/config"; // https://astro.build/config export default defineConfig({ site: "https://sfbrigade.github.io", - base: "/sfcivictech-site-explorations/packages/astro", + base: "/sfcivictech-site-explorations/packages/astro/", // site: "https://www.sfcivictech.org/" }); diff --git a/packages/astro/src/components/HeaderNav.astro b/packages/astro/src/components/HeaderNav.astro index b65677b..d5b5ad4 100644 --- a/packages/astro/src/components/HeaderNav.astro +++ b/packages/astro/src/components/HeaderNav.astro @@ -1,17 +1,18 @@ --- const routes = [ - ["/wiki", "Wiki"], - ["/getting-started", "Get Started"], - ["/events", "Events"], - ["/projects", "Projects"], - ["/blog", "Blog"], - ["/donate", "Donate"], - ["/about", "About"], + ["wiki", "Wiki"], + ["getting-started", "Get Started"], + ["events", "Events"], + ["projects", "Projects"], + ["blog", "Blog"], + ["donate", "Donate"], + ["about", "About"], ]; // because of annoying differences between dev and build modes, due to this // behavior (https://github.com/withastro/astro/issues/5630), always remove // any trailing slash so currentPath can match the paths above -const currentPath = Astro.url.pathname.replace(/\/$/, ""); +const fullPath = Astro.url.pathname.replace(/\/$/, ""); +const currentPath = fullPath.slice(fullPath.lastIndexOf("/") + 1); ---