Skip to content

Commit 811a142

Browse files
committed
Migrate content collections
1 parent 6930b54 commit 811a142

File tree

8 files changed

+21
-14
lines changed

8 files changed

+21
-14
lines changed

bun.lockb

7.7 KB
Binary file not shown.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"lint": "bunx --bun prettier . --check"
1313
},
1414
"dependencies": {
15-
"@astrojs/react": "3.6.2",
15+
"@astrojs/react": "4.0.0",
1616
"@iconify-json/bi": "^1.2.1",
1717
"@iconify-json/cil": "^1.2.1",
1818
"@iconify-json/fluent": "^1.2.7",
@@ -28,7 +28,7 @@
2828
"@iconify-json/uiw": "^1.2.1",
2929
"@types/react": "^18.3.12",
3030
"@types/react-dom": "^18.3.1",
31-
"astro": "4.16.13",
31+
"astro": "5.0.1",
3232
"astro-icon": "1.1.2",
3333
"astro-purgecss": "4.8.0",
3434
"autoprefixer": "^10.4.20",

src/content/config.ts renamed to src/content.config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
// 1. Import utilities from `astro:content`
1+
// 1. Import utilities from `astro:content`
22
import { z, defineCollection } from "astro:content";
3+
import { glob } from 'astro/loaders';
4+
35
// 2. Define your collection(s)
46
const testimonialCollection = defineCollection({
7+
loader: glob({ pattern: '**\/[^_]*.md', base: "./src/content/testimonials" }),
58
schema: ({ image }) =>
69
z.object({
710
title: z.string(),
@@ -13,6 +16,7 @@ const testimonialCollection = defineCollection({
1316
});
1417

1518
const sessionCollection = defineCollection({
19+
loader: glob({ pattern: '**\/[^_]*.md', base: "./src/content/sessions" }),
1620
schema: ({ image }) => {
1721
return z.object({
1822
title: z.string(),
@@ -32,6 +36,7 @@ const sessionCollection = defineCollection({
3236
});
3337

3438
const blogCollection = defineCollection({
39+
loader: glob({ pattern: '**\/[^_]*.md', base: "./src/content/blog" }),
3540
schema: ({ image }) => {
3641
return z.object({
3742
title: z.string(),

src/content/testimonials/DavidSchaefer.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
2+
id: david-schaefer
23
title: David Schaefer
34
preview: Each one, teach one
4-
isDraft: true
55
author: David Schaefer
6-
slug: david-schaefer
6+
isDraft: true
77
profilePicture: "../../images/authors/DavidSchaefer.jpg"
88
---
99

src/content/testimonials/EdgarGonzalez.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
2+
id: edgar-gonzalez
23
title: Edgar Gonzalez
34
preview: I went from zero to hero in no time
4-
isDraft: true
55
author: Edgar Gonzalez
6-
slug: edgar-gonzalez
6+
isDraft: true
77
profilePicture: "../../images/authors/EdgarGonzalez.jpg"
88
---
99

src/content/testimonials/FlorianVerdonck.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
2+
id: florian-verdonck
23
title: Florian Verdonck
34
preview: Open-source heavily influenced my career
4-
isDraft: true
55
author: Florian Verdonck
6-
slug: florian-verdonck
6+
isDraft: true
77
profilePicture: "../../images/authors/FlorianVerdonck.jpg"
88
---
99

src/pages/testimonials/[...slug].astro renamed to src/pages/testimonials/[...id].astro

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
import { getCollection } from "astro:content";
2+
import { getCollection, render } from "astro:content";
33
import PageLayout from "../../layouts/PageLayout.astro";
44
55
export async function getStaticPaths() {
@@ -9,14 +9,14 @@ export async function getStaticPaths() {
99
const prevTestimonial = testimonialsEntries.at(
1010
(index - 1) % testimonialsEntries.length,
1111
);
12-
const prevLink = prevTestimonial && prevTestimonial.slug;
12+
const prevLink = prevTestimonial && prevTestimonial.id;
1313
const nextTestimonial = testimonialsEntries.at(
1414
(index + 1) % testimonialsEntries.length,
1515
);
16-
const nextLink = nextTestimonial && nextTestimonial.slug;
16+
const nextLink = nextTestimonial && nextTestimonial.id;
1717
1818
return {
19-
params: { slug: entry.slug },
19+
params: { id: entry.id },
2020
props: {
2121
entry,
2222
prevLink,
@@ -28,7 +28,8 @@ export async function getStaticPaths() {
2828
}
2929
3030
const { entry, prevLink, nextLink, color } = Astro.props;
31-
const { Content } = await entry.render();
31+
const { Content } = await render(entry);
32+
console.log(entry);
3233
const { title, author, profilePicture } = entry.data;
3334
const pageTitle = `Testimonial of ${title}`;
3435
const mainTitle = pageTitle;

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"extends": "astro/tsconfigs/base",
33
"compilerOptions": {
44
"strictNullChecks": true,
5+
"allowJs": true, // required, and included with all Astro templates
56
"types": ["astro/client"],
67
"jsx": "react-jsx",
78
"jsxImportSource": "react"

0 commit comments

Comments
 (0)