Skip to content

Commit 8be9293

Browse files
Base path config and Links for github pages deploys
1 parent 8692e96 commit 8be9293

File tree

11 files changed

+56
-30
lines changed

11 files changed

+56
-30
lines changed

astro.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import icon from "astro-icon";
66

77
// https://astro.build/config
88
export default defineConfig({
9+
site: "https://owddm.com/chris-wireframe/",
10+
base: "/chris-wireframe/",
911
vite: {
1012
plugins: [tailwindcss()],
1113
},

src/components/Button.astro

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
22
import { Icon } from "astro-icon/components";
3+
import Link from "./Link.astro";
34
45
const { href, text, icon, class: className } = Astro.props;
56
---
67

7-
<a class:list={["btn btn-primary mx-auto", className]} href={href}>
8+
<Link class:list={["btn btn-primary mx-auto", className]} href={href}>
89
{text}
910
<Icon name={icon || "lucide:chevron-right"} />
10-
</a>
11+
</Link>

src/components/EventFeatured.astro

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { Icon } from "astro-icon/components";
33
import { type Event } from "../data";
44
import staticMap from "../assets/staticmap.png";
5+
import Link from "./Link.astro";
56
67
interface Props {
78
event: Event;
@@ -15,7 +16,7 @@ const formattedDate = new Date(event.date).toLocaleDateString("en-US", {
1516
});
1617
---
1718

18-
<a
19+
<Link
1920
class="card rounded-xl bg-base-100 h-full overflow-hidden hover-zoom flex flex-col lg:flex-row shadow-md w-full hover:shadow-lg"
2021
href={`/events/${event.id}`}
2122
>
@@ -85,4 +86,4 @@ const formattedDate = new Date(event.date).toLocaleDateString("en-US", {
8586
</div>
8687
</div>
8788
</div>
88-
</a>
89+
</Link>

src/components/EventPage.astro

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Icon } from "astro-icon/components";
66
import { events } from "../data";
77
import MemberSummary from "./MemberSummary.astro";
88
import EventGallery from "./EventGallery.astro";
9+
import Link from "./Link.astro";
910
1011
const { slug: eventId } = Astro.params;
1112
@@ -21,20 +22,20 @@ const nextEvent = currentIndex < events.length - 1 ? events[currentIndex + 1] :
2122
<div class="flex gap-4">
2223
{
2324
prevEvent && (
24-
<a href={`/events/${prevEvent.id}`} class="btn btn-soft gap-2">
25+
<Link href={`/events/${prevEvent.id}`} class="btn btn-soft gap-2">
2526
<Icon name="lucide:chevron-left" size={20} />
2627
Next Event
27-
</a>
28+
</Link>
2829
)
2930
}
3031
</div>
3132
<div class="flex gap-4">
3233
{
3334
nextEvent && (
34-
<a href={`/events/${nextEvent.id}`} class="btn btn-soft gap-2">
35+
<Link href={`/events/${nextEvent.id}`} class="btn btn-soft gap-2">
3536
Previous Event
3637
<Icon name="lucide:chevron-right" size={20} />
37-
</a>
38+
</Link>
3839
)
3940
}
4041
</div>

src/components/EventSummary.astro

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
import { Icon } from "astro-icon/components";
33
import { type Event } from "../data";
4+
import Link from "./Link.astro";
45
56
interface Props {
67
event: Event;
@@ -15,7 +16,7 @@ const formattedDate = new Date(event.date).toLocaleDateString("en-US", {
1516
});
1617
---
1718

18-
<a
19+
<Link
1920
href={`/events/${event.id}`}
2021
class={`card card-border bg-base-100 hover-zoom ${className ?? ""}`}
2122
>
@@ -52,4 +53,4 @@ const formattedDate = new Date(event.date).toLocaleDateString("en-US", {
5253
}
5354
</div>
5455
</div>
55-
</a>
56+
</Link>

src/components/Footer.astro

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import ThemePicker from "./ThemePicker.astro";
33
import Socials from "./Socials.astro";
44
import Container from "./Container.astro";
55
import { MENU, SITE } from "../config";
6+
import Link from "./Link.astro";
67
---
78

89
<footer class="bg-base-300 text-base-content">
@@ -11,9 +12,9 @@ import { MENU, SITE } from "../config";
1112
<nav class="flex gap-4">
1213
{
1314
MENU.map((item) => (
14-
<a href={item.href} class="link link-hover">
15+
<Link href={item.href} class="link link-hover">
1516
{item.label}
16-
</a>
17+
</Link>
1718
))
1819
}
1920
</nav>

src/components/Link.astro

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
// Link.astro: A drop-in replacement for <a> that prepends Astro.base to internal links
3+
const { href = "", ...props } = Astro.props;
4+
const isExternal =
5+
href.startsWith("http://") ||
6+
href.startsWith("https://") ||
7+
href.startsWith("mailto:") ||
8+
href.startsWith("tel:");
9+
const base = import.meta.env.BASE_URL;
10+
const finalHref = isExternal ? href : `${base}${href.replace(/^\//, "")}`;
11+
---
12+
13+
<a href={finalHref} {...props}><slot /></a>

src/components/MemberSummary.astro

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
import { type Member } from "../data";
3+
import Link from "./Link.astro";
34
45
interface Props {
56
member: Member;
@@ -8,7 +9,7 @@ interface Props {
89
const { member } = Astro.props;
910
---
1011

11-
<a
12+
<Link
1213
data-theme={member.theme}
1314
href={`/member/${member.id}`}
1415
class="hover-zoom relative card bg-primary-content text-primary"
@@ -37,4 +38,4 @@ const { member } = Astro.props;
3738
</div>
3839
</div>
3940
</div>
40-
</a>
41+
</Link>

src/components/TopBar.astro

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,23 @@
22
import { Icon } from "astro-icon/components";
33
import { MENU, SITE } from "../config";
44
import Container from "./Container.astro";
5+
import Link from "./Link.astro";
56
67
const items = MENU.filter((item) => item.header !== false);
78
---
89

910
<div class="navbar bg-base-100 fixed top-0 z-50 shadow-md">
1011
<Container class="flex justify-between">
1112
<div class="navbar-start">
12-
<a href="/" class="btn btn-ghost normal-case text-xl">{SITE.shortName}</a>
13+
<Link href="/" class="btn btn-ghost normal-case text-xl">{SITE.shortName}</Link>
1314
</div>
1415
<div class="navbar-end">
1516
<div class="hidden lg:flex">
1617
<ul class="menu menu-horizontal px-1">
1718
{
1819
items.map((item) => (
1920
<li>
20-
<a href={item.href}>{item.label}</a>
21+
<Link href={item.href}>{item.label}</Link>
2122
</li>
2223
))
2324
}
@@ -34,7 +35,7 @@ const items = MENU.filter((item) => item.header !== false);
3435
{
3536
items.map((item) => (
3637
<li>
37-
<a href={item.href}>{item.label}</a>
38+
<Link href={item.href}>{item.label}</Link>
3839
</li>
3940
))
4041
}

src/pages/community/[...filter].astro

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
import PageLayout from "../../layouts/PageLayout.astro";
33
import Section from "../../components/Section.astro";
4-
import Container from "../../components/Container.astro";
54
import MemberSummary from "../../components/MemberSummary.astro";
65
import { members, POSSIBLE_ROLES, ROLE_CONFIGS, type Role } from "../../data";
76
import { Icon } from "astro-icon/components";
7+
import Link from "../../components/Link.astro";
88
99
export function getStaticPaths() {
1010
return [...POSSIBLE_ROLES, undefined].map((role) => ({
@@ -27,21 +27,24 @@ const filteredMembers = members.filter((member) => {
2727
<div class="flex flex-col md:flex-row justify-between items-start md:items-center gap-4">
2828
<div class="w-full md:w-auto">
2929
<div class="join hidden md:flex">
30-
<a href="/community" class={`btn join-item ${filter === undefined ? "btn-primary" : ""}`}>
30+
<Link
31+
href="/community"
32+
class={`btn join-item ${filter === undefined ? "btn-primary" : ""}`}
33+
>
3134
<Icon name="lucide:users" size={20} class="mr-2" />
3235
Everyone
33-
</a>
36+
</Link>
3437
{
3538
POSSIBLE_ROLES.map((role) => {
3639
const config = ROLE_CONFIGS[role];
3740
return (
38-
<a
41+
<Link
3942
href={`/community/${role}`}
4043
class={`btn join-item ${filter === role ? "btn-primary" : ""}`}
4144
>
4245
<Icon name={config.icon} size={20} class="mr-2" />
4346
{config.plural}
44-
</a>
47+
</Link>
4548
);
4649
})
4750
}
@@ -56,20 +59,20 @@ const filteredMembers = members.filter((member) => {
5659
class="dropdown-content z-[1] menu p-2 shadow bg-base-100 rounded-box w-full"
5760
>
5861
<li>
59-
<a href="/community" class={filter === undefined ? "active" : ""}>
62+
<Link href="/community" class={filter === undefined ? "active" : ""}>
6063
<Icon name="lucide:users" size={20} class="mr-2" />
6164
Everyone
62-
</a>
65+
</Link>
6366
</li>
6467
{
6568
POSSIBLE_ROLES.map((role) => {
6669
const config = ROLE_CONFIGS[role];
6770
return (
6871
<li>
69-
<a href={`/community/${role}`} class={filter === role ? "active" : ""}>
72+
<Link href={`/community/${role}`} class={filter === role ? "active" : ""}>
7073
<Icon name={config.icon} size={20} class="mr-2" />
7174
{config.plural}
72-
</a>
75+
</Link>
7376
</li>
7477
);
7578
})

0 commit comments

Comments
 (0)