Skip to content

Commit 7d033df

Browse files
spboyerCopilot
andauthored
fix: make site base path configurable + remove unused workflow (#56)
* fix: make site base path configurable + remove unused workflow - Make astro.config.mjs read site/base from ASTRO_SITE and ASTRO_BASE env vars with GitHub Pages defaults. Azure SWA can now build with ASTRO_BASE=/ so images resolve correctly at root. - Remove unused squad-heartbeat.yml workflow. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: normalize base path and prevent // in nav links Address review feedback: normalize ASTRO_BASE to prevent double-slash URLs when base is '/'. Also fix Header.astro to strip trailing slash from BASE_URL before concatenating nav link paths. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent fd72379 commit 7d033df

3 files changed

Lines changed: 16 additions & 321 deletions

File tree

.github/workflows/squad-heartbeat.yml

Lines changed: 0 additions & 315 deletions
This file was deleted.

site/astro.config.mjs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@
22
import { defineConfig } from 'astro/config';
33
import starlight from '@astrojs/starlight';
44

5+
// Normalize base path: ensure leading slash, strip trailing slashes.
6+
const base = (() => {
7+
const raw = process.env.ASTRO_BASE ?? '/waza';
8+
if (!raw || raw === '/') return '/';
9+
const normalized = raw.startsWith('/') ? raw : `/${raw}`;
10+
return normalized.replace(/\/+$/, '') || '/';
11+
})();
12+
513
// https://astro.build/config
614
export default defineConfig({
7-
site: 'https://microsoft.github.io/waza',
8-
base: '/waza',
15+
site: process.env.ASTRO_SITE || 'https://microsoft.github.io/waza',
16+
base,
917
integrations: [
1018
starlight({
1119
title: 'waza',

site/src/components/Header.astro

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ import ThemeSelect from 'virtual:starlight/components/ThemeSelect';
1010
const shouldRenderSearch =
1111
config.pagefind || config.components.Search !== '@astrojs/starlight/components/Search.astro';
1212
13+
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
14+
1315
const navLinks = [
14-
{ label: 'Getting Started', href: `${import.meta.env.BASE_URL}/getting-started/` },
15-
{ label: 'Guides', href: `${import.meta.env.BASE_URL}/guides/eval-yaml/` },
16-
{ label: 'Reference', href: `${import.meta.env.BASE_URL}/reference/cli/` },
17-
{ label: 'About', href: `${import.meta.env.BASE_URL}/about/` },
16+
{ label: 'Getting Started', href: `${base}/getting-started/` },
17+
{ label: 'Guides', href: `${base}/guides/eval-yaml/` },
18+
{ label: 'Reference', href: `${base}/reference/cli/` },
19+
{ label: 'About', href: `${base}/about/` },
1820
];
1921
2022
const currentPath = Astro.url.pathname;

0 commit comments

Comments
 (0)