Skip to content

Commit 0eef288

Browse files
committed
fix(nav): generate relative URLs with base value
https://docs.astro.build/en/reference/configuration-reference/#base
1 parent 591675a commit 0eef288

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

astro.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import tailwindcss from '@tailwindcss/vite'
66
export default defineConfig({
77
site: 'https://pokeapi.co',
88
base: '',
9+
trailingSlash: "always",
910
integrations: [
1011
starlight({
1112
title: 'PokéAPI',

src/components/PokeNav.astro

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
const baseUrl = import.meta.env.BASE_URL
3+
const about = baseUrl + 'about/'
4+
const v2 = baseUrl + 'v2/'
5+
const graphql = baseUrl + 'graphql/'
6+
---
17
<nav>
28
<ul
39
class="
@@ -9,16 +15,16 @@
915
"
1016
>
1117
<li>
12-
<a href="/">Home</a>
18+
<a href={baseUrl}>Home</a>
1319
</li>
1420
<li>
15-
<a href="/about">About</a>
21+
<a href={about}>About</a>
1622
</li>
1723
<li>
18-
<a href="/v2">API v2</a>
24+
<a href={v2}>API v2</a>
1925
</li>
2026
<li>
21-
<a href="/graphql">GraphQL v1Beta</a>
27+
<a href={graphql}>GraphQL v1Beta</a>
2228
</li>
2329
</ul>
2430
</nav>

0 commit comments

Comments
 (0)