From 5d56e7eeed9357299c2b06762ce9719c3630329e Mon Sep 17 00:00:00 2001 From: Corwin Perren Date: Sun, 23 Mar 2025 23:31:05 -0700 Subject: [PATCH] Add experience pages --- src/content/config.ts | 6 +++++- src/pages/experience/[id].astro | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/pages/experience/[id].astro diff --git a/src/content/config.ts b/src/content/config.ts index 5b077cd..fb81706 100644 --- a/src/content/config.ts +++ b/src/content/config.ts @@ -5,6 +5,10 @@ import { defineCollection } from 'astro:content'; import { glob } from 'astro/loaders'; // 3. Define your collection(s) +const experiences = defineCollection({ + loader: glob({ pattern: "*.md", base: "src/content/experience" }) +}) + const projects = defineCollection({ loader: glob({ pattern: "*.md", base: "src/content/projects" }) }) @@ -13,4 +17,4 @@ const hobbies = defineCollection({ }) // 4. Export a single `collections` object to register your collection(s) -export const collections = { projects, hobbies }; \ No newline at end of file +export const collections = { experiences, projects, hobbies }; \ No newline at end of file diff --git a/src/pages/experience/[id].astro b/src/pages/experience/[id].astro new file mode 100644 index 0000000..bb3b791 --- /dev/null +++ b/src/pages/experience/[id].astro @@ -0,0 +1,18 @@ +--- +import {getCollection, render} from 'astro:content'; +import BaseLayout from "../../layouts/BaseLayout.astro"; +// 1. Generate a new path for every collection entry +export async function getStaticPaths() { + const experiences = await getCollection('experiences'); + return experiences.map(experience => ({ + params: {id: experience.id}, + props: {project: experience}, + })); +} +// 2. For your template, you can get the entry directly from the prop +const {experience} = Astro.props; +const {Content} = await render(experience); +--- + + + \ No newline at end of file