Luke Jones

lukeonline - commit 4dc9250

feat: load repo data into astro pages4dc9250e98017704a5e682984b6ca5fea3dcc908LukeJ<luke.jones.2567@gmail.com>2026-09-29T20:12:17+01:00
diff --git a/src/content.config.ts b/src/content.config.ts index 340b722..270be81 100644 --- a/src/content.config.ts +++ b/src/content.config.ts @@ -12,4 +12,11 @@ const photos = defineCollection({ loader: file('./src/content/photos/photos.json'), }) -export const collections = { blog, photos } +const repos = defineCollection({ + loader: glob({ + base: './src/content/repos', + pattern: '**/repo.json', + }) +}) + +export const collections = { blog, photos, repos } diff --git a/src/pages/projects/[name].astro b/src/pages/projects/[name].astro new file mode 100644 index 0000000..49a1ac9 --- /dev/null +++ b/src/pages/projects/[name].astro @@ -0,0 +1,23 @@ +--- +import Base from '../../layouts/Base.astro' + +import { getCollection, render } from 'astro:content' + +export async function getStaticPaths() { + const repos = await getCollection('repos') + + return repos.map((repo) => ({ + params: { + name: repo.data.name, + }, + props: { + repo, + }, + })) +} + +const { repo } = Astro.props +--- + +<Base title={repo.data.name}> +</Base> diff --git a/src/pages/projects/index.astro b/src/pages/projects/index.astro index 7b86e89..af6b15a 100644 --- a/src/pages/projects/index.astro +++ b/src/pages/projects/index.astro @@ -1,38 +1,19 @@ --- import ContentList from '../../layouts/ContentList.astro' -import TextSection from '../../components/TextSection.astro' import { getCollection, getEntry } from 'astro:content' const title = 'Projects' -const contentData = [ - { - title: 'got', - desc: 'Basic shell script for quickly storing, managing, and changing-to directories on your machine.', - link: 'https://github.com/LukePJ25/got', - }, - { - title: 'JSDiver', - desc: 'A basic skydiving game implemented through use of the HTML5 Canvas.', - link: '/blog/141124', - }, - { - title: 'Intervle', - desc: 'Web-based event-ordering game written in PHP with Laravel 12', - link: 'https://github.com/LukePJ25/Intervle', - }, - { - title: 'lukeonline', - desc: 'This website. Rewritten in Astro.', - link: 'https://github.com/LukePJ25/lukeonline', - }, - { - title: 'ChickenBoard', - desc: 'A basic canvas-based drawing program.', - link: 'https://github.com/LukePJ25/ChickenBoard/', - }, -] +const repos = await getCollection('repos') + +const repoUrl = '/projects/' + +const contentData = repos.map((repo) => ({ + title: `${repo.data.name}`, + link: `${repoUrl}${repo.data.name}`, +})) +console.log(repos) --- <ContentList title={title} content={contentData} />