Skip to content

Commit 21497be

Browse files
committed
feat(projects): add github source link support to project listing and detail pages
1 parent b4bb12c commit 21497be

File tree

2 files changed

+39
-11
lines changed

2 files changed

+39
-11
lines changed

src/pages/projects/[slug].astro

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import Layout from '@layouts/Default.astro';
33
import data from '@data/projects.json';
44
55
export async function getStaticPaths() {
6-
// Extract all years (keys) from the data object
76
const years = Object.keys(data);
8-
// Flatten all projects from all years into a single array
97
const allProjects = years.flatMap(year => data[year]);
108
119
return allProjects.map(project => ({
@@ -16,6 +14,7 @@ export async function getStaticPaths() {
1614
1715
const { project } = Astro.props;
1816
17+
// Robust MDX loading
1918
const allProjectMdxFiles = import.meta.glob('/src/data/projects/*.mdx', { eager: true });
2019
const matchingPath = Object.keys(allProjectMdxFiles)
2120
.find(path => path.endsWith(`${project.slug}.mdx`));
@@ -31,6 +30,17 @@ const { Content } = mdxModule;
3130
<Layout title={`Project: ${project.title}`}>
3231
<section class="section">
3332
<div class="container content">
33+
34+
<!-- GitHub Button (Only shows if link exists) -->
35+
{project.githubLink && (
36+
<div class="buttons mb-5">
37+
<a href={project.githubLink} target="_blank" rel="noopener noreferrer" class="button is-dark">
38+
<span class="icon"><i class="fa-brands fa-github"></i></span>
39+
<span>View Source Code on GitHub</span>
40+
</a>
41+
</div>
42+
)}
43+
3444
<Content />
3545

3646
{project.leads && project.leads.length > 0 && (

src/pages/projects/index.astro

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,20 @@ const archiveYears = years.slice(1);
2929
<h2 class="title">{project.emoji} {project.title}</h2>
3030
<h4 class="subtitle">{project.name}</h4>
3131
<p>{project.desc}</p>
32-
<a href={`/projects/${project.slug}`} class="button is-info">
33-
<span>View Project Details</span>
34-
<span class="icon is-small">
35-
<i class="fa-solid fa-arrow-right"></i>
36-
</span>
37-
</a>
32+
33+
<div class="buttons">
34+
<a href={`/projects/${project.slug}`} class="button is-info">
35+
<span>View Project Details</span>
36+
<span class="icon is-small"><i class="fa-solid fa-arrow-right"></i></span>
37+
</a>
38+
{project.githubLink && (
39+
<a href={project.githubLink} target="_blank" rel="noopener noreferrer" class="button is-dark is-outlined">
40+
<span class="icon"><i class="fa-brands fa-github"></i></span>
41+
<span>Source Code</span>
42+
</a>
43+
)}
44+
</div>
45+
3846
</div>
3947
</div>
4048
</article>
@@ -57,9 +65,19 @@ const archiveYears = years.slice(1);
5765
<div class="content">
5866
<h3 class="title is-5">{project.emoji} {project.title}</h3>
5967
<p>{project.desc}</p>
60-
<a href={`/projects/${project.slug}`} class="button is-small is-info is-outlined">
61-
<span>View Project</span>
62-
</a>
68+
69+
<div class="buttons is-small">
70+
<a href={`/projects/${project.slug}`} class="button is-small is-info is-outlined">
71+
<span>View Project</span>
72+
</a>
73+
{project.githubLink && (
74+
<a href={project.githubLink} target="_blank" rel="noopener noreferrer" class="button is-small is-dark is-outlined">
75+
<span class="icon"><i class="fa-brands fa-github"></i></span>
76+
<span>Source</span>
77+
</a>
78+
)}
79+
</div>
80+
6381
</div>
6482
</div>
6583
</article>

0 commit comments

Comments
 (0)