Skip to content

Commit 8983475

Browse files
authored
Merge pull request #5 from mag1cfrog/dev/astro-migration
Dev/astro migration
2 parents d2a14d5 + 475eb90 commit 8983475

4 files changed

Lines changed: 24 additions & 19 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Setup Node.js
2424
uses: actions/setup-node@v3
2525
with:
26-
node-version: "18"
26+
node-version: "22"
2727
- name: Install & build
2828
run: |
2929
npm ci

astro.config.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import sitemap from '@astrojs/sitemap';
55

66
// https://astro.build/config
77
export default defineConfig({
8-
site: 'https://mag1cfrog.github.io',
9-
base: '/spark-tuning-notes/',
8+
site: 'https://mag1cfrog.github.io/spark-tuning-notes/',
109
output: 'static',
1110
integrations: [mdx(), sitemap()],
1211
});
12+

src/components/HeaderLink.astro

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
---
22
import type { HTMLAttributes } from 'astro/types';
33
4-
type Props = HTMLAttributes<'a'>;
4+
/* 1️⃣ Force href to be a string so TS stops complaining */
5+
interface Props extends Omit<HTMLAttributes<'a'>, 'href'> {
6+
href: string;
7+
}
8+
const { href, class: className, ...rest } = Astro.props as Props;
59
6-
const { href, class: className, ...props } = Astro.props;
7-
const pathname = Astro.url.pathname.replace(import.meta.env.BASE_URL, '');
8-
const subpath = pathname.match(/[^\/]+/g);
9-
const isActive = href === pathname || href === '/' + (subpath?.[0] || '');
10+
/* 2️⃣ Build the correct URL (adds `/spark-tuning-notes/` in prod) */
11+
const finalHref = (Astro as any).resolve?.(href) ?? href; // e.g. "/spark-tuning-notes/blog"
12+
13+
/* 3️⃣ Active-link logic – compare full paths */
14+
const current = Astro.url.pathname; // already includes base
15+
const isActive = finalHref === current ||
16+
(current.startsWith(finalHref) && href !== '/');
17+
18+
/* 4️⃣ Combine classes */
19+
const classes = [className, { active: isActive }];
1020
---
1121

12-
<a href={href} class:list={[className, { active: isActive }]} {...props}>
13-
<slot />
22+
<a href={finalHref} class:list={classes} {...rest}>
23+
<slot />
1424
</a>
25+
1526
<style>
16-
a {
17-
display: inline-block;
18-
text-decoration: none;
19-
}
20-
a.active {
21-
font-weight: bolder;
22-
text-decoration: underline;
23-
}
27+
a { display:inline-block; text-decoration:none; }
28+
a.active { font-weight:bold; text-decoration:underline; }
2429
</style>

src/pages/about.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
import Layout from '../layouts/BlogPost.astro';
3-
import AboutHeroImage from '../assets/blog-placeholder-about.jpg';
3+
// import AboutHeroImage from '../assets/blog-placeholder-about.jpg';
44
---
55

66
<Layout

0 commit comments

Comments
 (0)