Skip to content

Commit

Permalink
Add <base> tag to fix URLs when hosted at a path
Browse files Browse the repository at this point in the history
Fix path handling in HeaderNav.astro.
Fix titles on all pages.
  • Loading branch information
fwextensions committed Jan 13, 2024
1 parent 5a4fd87 commit f1073b0
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
});
17 changes: 9 additions & 8 deletions packages/astro/src/components/HeaderNav.astro
Original file line number Diff line number Diff line change
@@ -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);
---

<nav class="container-fluid">
Expand Down
1 change: 1 addition & 0 deletions packages/astro/src/layouts/Page.astro
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const { title } = Astro.props;
<!doctype html>
<html lang="en">
<head>
<base href={import.meta.env.BASE_URL} />
<meta charset="UTF-8" />
<meta name="description" content="Astro description" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/pages/about.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
import BaseLayout from "@/layouts/BaseLayout.astro";
---

<BaseLayout title="Donate">
<BaseLayout title="About">
<p>About</p>
</BaseLayout>
4 changes: 2 additions & 2 deletions packages/astro/src/pages/blog.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import BaseLayout from "@/layouts/BaseLayout.astro";
const posts = await getCollection("blog");
---

<BaseLayout title="Donate">
<BaseLayout title="Blog">
<ul>
{
posts.map((post) => (
<li>
<a href={"/blog/" + post.slug}>{post.data.title}</a>
<a href={"blog/" + post.slug}>{post.data.title}</a>
</li>
))
}
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/pages/events.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
import BaseLayout from "@/layouts/BaseLayout.astro";
---

<BaseLayout title="Donate">
<BaseLayout title="Events">
<p>Events</p>
</BaseLayout>
2 changes: 1 addition & 1 deletion packages/astro/src/pages/getting-started.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
import BaseLayout from "@/layouts/BaseLayout.astro";
---

<BaseLayout title="Donate">
<BaseLayout title="Getting Started">
<p>Getting started</p>
</BaseLayout>
2 changes: 1 addition & 1 deletion packages/astro/src/pages/projects.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
import BaseLayout from "@/layouts/BaseLayout.astro";
---

<BaseLayout title="Donate">
<BaseLayout title="Projects">
<p>Projects</p>
</BaseLayout>
2 changes: 1 addition & 1 deletion packages/astro/src/pages/wiki.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
import BaseLayout from "@/layouts/BaseLayout.astro";
---

<BaseLayout title="Donate">
<BaseLayout title="Wiki">
<p>Wiki</p>
</BaseLayout>

0 comments on commit f1073b0

Please sign in to comment.