Skip to content

Commit ba361dd

Browse files
committed
fix: add content schema and fix slug ids
1 parent d3dc624 commit ba361dd

File tree

9 files changed

+146
-15
lines changed

9 files changed

+146
-15
lines changed

src/components/services-list.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { services } = Astro.props;
77
{services.map((service) => (
88
<li class={`overflow-clip bg-light-surface dark:bg-dark-surface shadow-2xl relative px-6 py-6 flex animate__animated animate__fadeIn`}
99
data-tags={`${service.tags?.join(",")}`}>
10-
<a href={`/services/${service.id}`}>
10+
<a href={`/services/${service.slug}`}>
1111
{service.tags.includes("service") && (
1212
<span class="absolute shadow top-0 z-10 text-xs right-0 text-white bg-brand-primary px-1.5 py-0.5 rounded-bl opacity-75">
1313
Node Service

src/content/config.ts

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
import { defineCollection, z } from 'astro:content';
2+
3+
const news = defineCollection({
4+
type: 'content',
5+
schema: z.object({
6+
title: z.string(),
7+
date: z.string(),
8+
summary: z.string(),
9+
cover: z.object({
10+
source: z.string(),
11+
}).optional(),
12+
layout: z.string().optional(),
13+
variant: z.string().optional(),
14+
}),
15+
});
16+
17+
const services = defineCollection({
18+
type: 'content',
19+
schema: z.object({
20+
title: z.string(),
21+
summary: z.string(),
22+
logo: z.string().optional(),
23+
tags: z.array(z.string()).optional(),
24+
layout: z.string().optional(),
25+
variant: z.string().optional(),
26+
}),
27+
});
28+
29+
const events = defineCollection({
30+
type: 'content',
31+
schema: z.object({
32+
title: z.string(),
33+
date: z.string(),
34+
summary: z.string(),
35+
cover: z.object({
36+
source: z.string(),
37+
}).optional(),
38+
layout: z.string().optional(),
39+
variant: z.string().optional(),
40+
}),
41+
});
42+
43+
const about = defineCollection({
44+
type: 'content',
45+
schema: z.object({
46+
title: z.string(),
47+
summary: z.string().optional(),
48+
logo: z.string().optional(),
49+
layout: z.string().optional(),
50+
variant: z.string().optional(),
51+
}),
52+
});
53+
54+
const fundingAndProjects = defineCollection({
55+
type: 'content',
56+
schema: z.object({
57+
title: z.string(),
58+
summary: z.string().optional(),
59+
date: z.string().optional(),
60+
cover: z.object({
61+
source: z.string(),
62+
}).optional(),
63+
layout: z.string().optional(),
64+
variant: z.string().optional(),
65+
}),
66+
});
67+
68+
const accessibility = defineCollection({
69+
type: 'content',
70+
schema: z.object({
71+
title: z.string(),
72+
layout: z.string().optional(),
73+
variant: z.string().optional(),
74+
}),
75+
});
76+
77+
const banner = defineCollection({
78+
type: 'content',
79+
schema: z.object({
80+
title: z.string(),
81+
layout: z.string().optional(),
82+
variant: z.string().optional(),
83+
}),
84+
});
85+
86+
const landing = defineCollection({
87+
type: 'content',
88+
schema: z.object({
89+
title: z.string(),
90+
layout: z.string().optional(),
91+
variant: z.string().optional(),
92+
}),
93+
});
94+
95+
const researchSupport = defineCollection({
96+
type: 'content',
97+
schema: z.object({
98+
title: z.string(),
99+
summary: z.string().optional(),
100+
layout: z.string().optional(),
101+
variant: z.string().optional(),
102+
}),
103+
});
104+
105+
const training = defineCollection({
106+
type: 'content',
107+
schema: z.object({
108+
title: z.string(),
109+
summary: z.string().optional(),
110+
date: z.string().optional(),
111+
layout: z.string().optional(),
112+
variant: z.string().optional(),
113+
}),
114+
});
115+
116+
export const collections = {
117+
news,
118+
services,
119+
events,
120+
about,
121+
'funding-and-projects': fundingAndProjects,
122+
accessibility,
123+
banner,
124+
landing,
125+
'research-support': researchSupport,
126+
training,
127+
};

src/pages/about/[...organization].astro

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ export const prerender = true;
66
77
export async function getStaticPaths() {
88
const organizations = await getCollection("about");
9-
return organizations.map((entry) => ({
10-
params: {
11-
organization: entry.id,
12-
},
13-
props: {
14-
entry,
15-
},
16-
}));
9+
return organizations.map((entry) => {
10+
console.log(entry)
11+
return ({
12+
params: {
13+
organization: entry.slug,
14+
},
15+
props: {
16+
entry,
17+
},
18+
})
19+
});
1720
}
1821
const { entry } = Astro.props;
1922
const { Content } = await render(entry);

src/pages/events/[...events].astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export async function getStaticPaths() {
99
return events.map((entry) => {
1010
return {
1111
params: {
12-
events: entry.id,
12+
events: entry.slug,
1313
},
1414
props: {
1515
entry,

src/pages/events/index.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ events.sort((a, b) => parseDate(b.data.date) - parseDate(a.data.date));
2626
events.map((entry) => {
2727
return (
2828
<CardV2
29-
link={`/events/${entry.id}`}
29+
link={`/events/${entry.slug}`}
3030
title={entry.data.title}
3131
summary={entry.data.summary}
3232
cover={entry.data?.cover?.source}

src/pages/funding-and-projects/[...project].astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export async function getStaticPaths() {
88
const projects = await getCollection("funding-and-projects");
99
return projects.map((entry) => ({
1010
params: {
11-
project: entry.id,
11+
project: entry.slug,
1212
},
1313
props: {
1414
entry,

src/pages/news/[...news].astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
import { getCollection, render } from "astro:content";
3+
import type { CollectionEntry } from "astro:content";
34
import { components } from "../../components/elements";
45
56
export const prerender = true;
@@ -13,7 +14,7 @@ export async function getStaticPaths() {
1314
];
1415
return {
1516
params: {
16-
news: entry.id,
17+
news: entry.slug,
1718
},
1819
props: {
1920
entry,

src/pages/news/index.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ news.sort((a, b) => parseDate(b.data.date) - parseDate(a.data.date));
2929
{news.map((entry) => {
3030
return (
3131
<CardV2
32-
link={`/news/${entry.id}`}
32+
link={`/news/${entry.slug}`}
3333
title={entry.data.title}
3434
summary={entry.data.summary}
3535
cover={entry.data?.cover?.source}

src/pages/services/[...service].astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export async function getStaticPaths() {
88
const services = await getCollection("services");
99
return services.map((entry) => ({
1010
params: {
11-
service: entry.id,
11+
service: entry.slug,
1212
},
1313
props: {
1414
entry,

0 commit comments

Comments
 (0)