Skip to content

Commit 90acf98

Browse files
authored
Merge pull request #4 from ruivieira/fix-paths-all
fix: Fix relative paths
2 parents eaf515b + 9ff7271 commit 90acf98

File tree

9 files changed

+116
-29
lines changed

9 files changed

+116
-29
lines changed

src/components/BaseHead.astro

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,32 @@ const { title, description, image = `${baseUrl}/blog-placeholder-1.jpg` } = Astr
3131
/>
3232
<meta name="generator" content={Astro.generator} />
3333

34+
<!-- Font preloads -->
35+
<link rel="preload" href={fontRegularUrl} as="font" type="font/woff" crossorigin />
36+
<link rel="preload" href={fontBoldUrl} as="font" type="font/woff" crossorigin />
37+
3438
<!-- Font definitions -->
35-
<style define:vars={{ fontRegularUrl, fontBoldUrl }}>
39+
<style set:html={`
3640
@font-face {
3741
font-family: 'Atkinson';
38-
src: url(var(--fontRegularUrl)) format('woff');
39-
font-weight: 400;
42+
src: url('${fontRegularUrl}') format('woff');
43+
font-weight: normal;
4044
font-style: normal;
4145
font-display: swap;
4246
}
4347
@font-face {
4448
font-family: 'Atkinson';
45-
src: url(var(--fontBoldUrl)) format('woff');
46-
font-weight: 700;
49+
src: url('${fontBoldUrl}') format('woff');
50+
font-weight: bold;
4751
font-style: normal;
4852
font-display: swap;
4953
}
50-
</style>
51-
52-
<!-- Font preloads -->
53-
<link rel="preload" href={fontRegularUrl} as="font" type="font/woff" crossorigin />
54-
<link rel="preload" href={fontBoldUrl} as="font" type="font/woff" crossorigin />
54+
55+
/* Ensure the font is applied */
56+
body {
57+
font-family: 'Atkinson', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
58+
}
59+
`}></style>
5560

5661
<!-- Canonical URL -->
5762
<link rel="canonical" href={canonicalURL} />

src/components/Header.astro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import { SITE_TITLE } from '../consts';
77
<nav>
88
<div class="site-branding">
99
<img src={`${import.meta.env.BASE_URL}/trustyai-logo.svg`} alt="TrustyAI Logo" class="logo" />
10-
<h2><a href="./">{SITE_TITLE}</a></h2>
10+
<h2><a href={`${import.meta.env.BASE_URL}/`}>{SITE_TITLE}</a></h2>
1111
</div>
1212
<div class="internal-links">
13-
<HeaderLink href="blog/research">Research</HeaderLink>
14-
<HeaderLink href="blog/engineering">Engineering</HeaderLink>
13+
<HeaderLink href={`${import.meta.env.BASE_URL}/research`}>Research</HeaderLink>
14+
<HeaderLink href={`${import.meta.env.BASE_URL}/engineering`}>Engineering</HeaderLink>
1515
<HeaderLink href="https://trustyai-explainability.github.io/trustyai-site/main/main.html" target="_blank">Documentation</HeaderLink>
1616
</div>
1717
<div class="social-links">

src/layouts/BlogPost.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const { title, description, pubDate, updatedDate, heroImage } = Astro.props;
5959
<main>
6060
<article>
6161
<div class="hero-image">
62-
{heroImage && <img width={1020} height={510} src={heroImage.startsWith('/') ? `${import.meta.env.BASE_URL}${heroImage.slice(1)}` : heroImage} alt="" />}
62+
{heroImage && <img width={1020} height={510} src={heroImage.startsWith('/') ? `${import.meta.env.BASE_URL}/${heroImage.slice(1)}` : heroImage} alt="" />}
6363
</div>
6464
<div class="prose">
6565
<div class="title">

src/pages/blog/index.astro

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ const getImageUrl = (heroImage) => {
1818
if (!heroImage) return '';
1919
return heroImage.startsWith('/') ? `${import.meta.env.BASE_URL}/${heroImage.slice(1)}` : heroImage;
2020
};
21+
22+
// Helper function to get the correct post URL
23+
const getPostUrl = (post) => {
24+
if (post.data.track === 'research') {
25+
return `${import.meta.env.BASE_URL}/research/${post.id.replace('research/', '')}`;
26+
} else if (post.data.track === 'engineering') {
27+
return `${import.meta.env.BASE_URL}/engineering/${post.id.replace('engineering/', '')}`;
28+
} else {
29+
// For posts not in subdirectories
30+
return `${import.meta.env.BASE_URL}/blog/${post.id}`;
31+
}
32+
};
2133
---
2234

2335
<!doctype html>
@@ -113,7 +125,7 @@ const getImageUrl = (heroImage) => {
113125
{
114126
researchPosts.map((post) => (
115127
<li>
116-
<a href={`/blog/${post.id}/`}>
128+
<a href={getPostUrl(post)}>
117129
<img width={720} height={360} src={getImageUrl(post.data.heroImage)} alt="" />
118130
<h4 class="title">{post.data.title}</h4>
119131
<p class="date">
@@ -132,7 +144,7 @@ const getImageUrl = (heroImage) => {
132144
{
133145
engineeringPosts.map((post) => (
134146
<li>
135-
<a href={`/blog/${post.id}/`}>
147+
<a href={getPostUrl(post)}>
136148
<img width={720} height={360} src={getImageUrl(post.data.heroImage)} alt="" />
137149
<h4 class="title">{post.data.title}</h4>
138150
<p class="date">
Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
import BaseHead from '../../components/BaseHead.astro';
3-
import Header from '../../components/Header.astro';
4-
import Footer from '../../components/Footer.astro';
5-
import { SITE_TITLE, SITE_DESCRIPTION } from '../../consts';
2+
import BaseHead from '../components/BaseHead.astro';
3+
import Header from '../components/Header.astro';
4+
import Footer from '../components/Footer.astro';
5+
import { SITE_TITLE, SITE_DESCRIPTION } from '../consts';
66
import { getCollection } from 'astro:content';
7-
import FormattedDate from '../../components/FormattedDate.astro';
7+
import FormattedDate from '../components/FormattedDate.astro';
88
99
const posts = (await getCollection('blog'))
1010
.filter(post => post.data.track === 'engineering')
@@ -15,6 +15,11 @@ const getImageUrl = (heroImage) => {
1515
if (!heroImage) return '';
1616
return heroImage.startsWith('/') ? `${import.meta.env.BASE_URL}/${heroImage.slice(1)}` : heroImage;
1717
};
18+
19+
// Helper function to get the correct post URL for engineering posts
20+
const getPostUrl = (post) => {
21+
return `${import.meta.env.BASE_URL}/engineering/${post.id.replace('engineering/', '')}`;
22+
};
1823
---
1924

2025
<!doctype html>
@@ -119,7 +124,7 @@ const getImageUrl = (heroImage) => {
119124
{
120125
posts.map((post) => (
121126
<li>
122-
<a href={`/blog/${post.id}/`}>
127+
<a href={getPostUrl(post)}>
123128
<img width={720} height={360} src={getImageUrl(post.data.heroImage)} alt="" />
124129
<h4 class="title">{post.data.title}</h4>
125130
<p class="date">

src/pages/engineering/[slug].astro

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
import { type CollectionEntry, getCollection } from 'astro:content';
3+
import BlogPost from '../../layouts/BlogPost.astro';
4+
import { render } from 'astro:content';
5+
6+
export async function getStaticPaths() {
7+
const posts = await getCollection('blog');
8+
const engineeringPosts = posts.filter(post => post.data.track === 'engineering');
9+
10+
return engineeringPosts.map((post) => ({
11+
params: { slug: post.id.replace('engineering/', '') },
12+
props: post,
13+
}));
14+
}
15+
16+
type Props = CollectionEntry<'blog'>;
17+
18+
const post = Astro.props;
19+
const { Content } = await render(post);
20+
---
21+
22+
<BlogPost {...post.data}>
23+
<Content />
24+
</BlogPost>

src/pages/index.astro

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ const getImageUrl = (heroImage) => {
1515
if (!heroImage) return '';
1616
return heroImage.startsWith('/') ? `${import.meta.env.BASE_URL}/${heroImage.slice(1)}` : heroImage;
1717
};
18+
19+
// Helper function to get the correct post URL
20+
const getPostUrl = (post) => {
21+
if (post.data.track === 'research') {
22+
return `${import.meta.env.BASE_URL}/research/${post.id.replace('research/', '')}`;
23+
} else if (post.data.track === 'engineering') {
24+
return `${import.meta.env.BASE_URL}/engineering/${post.id.replace('engineering/', '')}`;
25+
} else {
26+
// For posts not in subdirectories
27+
return `${import.meta.env.BASE_URL}/blog/${post.id}`;
28+
}
29+
};
1830
---
1931

2032
<!doctype html>
@@ -143,7 +155,7 @@ const getImageUrl = (heroImage) => {
143155
<span class={`track-badge ${post.data.track}`}>
144156
{post.data.track}
145157
</span>
146-
<a href={`/blog/${post.id}/`}>
158+
<a href={getPostUrl(post)}>
147159
<img width={720} height={360} src={getImageUrl(post.data.heroImage)} alt="" />
148160
<h4 class="title">{post.data.title}</h4>
149161
<p class="date">
Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
import BaseHead from '../../components/BaseHead.astro';
3-
import Header from '../../components/Header.astro';
4-
import Footer from '../../components/Footer.astro';
5-
import { SITE_TITLE, SITE_DESCRIPTION } from '../../consts';
2+
import BaseHead from '../components/BaseHead.astro';
3+
import Header from '../components/Header.astro';
4+
import Footer from '../components/Footer.astro';
5+
import { SITE_TITLE, SITE_DESCRIPTION } from '../consts';
66
import { getCollection } from 'astro:content';
7-
import FormattedDate from '../../components/FormattedDate.astro';
7+
import FormattedDate from '../components/FormattedDate.astro';
88
99
const posts = (await getCollection('blog'))
1010
.filter(post => post.data.track === 'research')
@@ -15,6 +15,11 @@ const getImageUrl = (heroImage) => {
1515
if (!heroImage) return '';
1616
return heroImage.startsWith('/') ? `${import.meta.env.BASE_URL}/${heroImage.slice(1)}` : heroImage;
1717
};
18+
19+
// Helper function to get the correct post URL for research posts
20+
const getPostUrl = (post) => {
21+
return `${import.meta.env.BASE_URL}/research/${post.id.replace('research/', '')}`;
22+
};
1823
---
1924

2025
<!doctype html>
@@ -119,7 +124,7 @@ const getImageUrl = (heroImage) => {
119124
{
120125
posts.map((post) => (
121126
<li>
122-
<a href={`/blog/${post.id}/`}>
127+
<a href={getPostUrl(post)}>
123128
<img width={720} height={360} src={getImageUrl(post.data.heroImage)} alt="" />
124129
<h4 class="title">{post.data.title}</h4>
125130
<p class="date">

src/pages/research/[slug].astro

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
import { type CollectionEntry, getCollection } from 'astro:content';
3+
import BlogPost from '../../layouts/BlogPost.astro';
4+
import { render } from 'astro:content';
5+
6+
export async function getStaticPaths() {
7+
const posts = await getCollection('blog');
8+
const researchPosts = posts.filter(post => post.data.track === 'research');
9+
10+
return researchPosts.map((post) => ({
11+
params: { slug: post.id.replace('research/', '') },
12+
props: post,
13+
}));
14+
}
15+
16+
type Props = CollectionEntry<'blog'>;
17+
18+
const post = Astro.props;
19+
const { Content } = await render(post);
20+
---
21+
22+
<BlogPost {...post.data}>
23+
<Content />
24+
</BlogPost>

0 commit comments

Comments
 (0)