Skip to content

Commit 33feff9

Browse files
committed
Set up local blog
1 parent 2f3809f commit 33feff9

File tree

5 files changed

+108
-101
lines changed

5 files changed

+108
-101
lines changed

www/src/content.config.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { z, defineCollection } from 'astro:content';
2+
import { file, glob } from 'astro/loaders';
3+
4+
const DATE = z
5+
.string()
6+
.or(z.date())
7+
.transform((val) => new Date(val));
8+
9+
const w3c = defineCollection({
10+
loader: file('src/content/w3c.json'),
11+
schema: () =>
12+
z.object({
13+
title: z.string(),
14+
date: DATE,
15+
author: z.string(),
16+
url: z.string(),
17+
}),
18+
});
19+
20+
const posts = defineCollection({
21+
loader: glob({ pattern: ['*.md'], base: 'src/content/posts' }),
22+
schema: () =>
23+
z.object({
24+
title: z.string(),
25+
date: DATE,
26+
description: z.optional(z.string()),
27+
author: z.string(),
28+
tags: z.optional(z.array(z.string())),
29+
}),
30+
});
31+
32+
export const collections = {
33+
posts,
34+
w3c,
35+
};

www/src/content/config.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

www/src/content/posts.ts

Lines changed: 0 additions & 54 deletions
This file was deleted.

www/src/content/w3c.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
[
2+
{
3+
"id": "call-to-read-the-first-public-editors-draft-and-share-feedback",
4+
"title": "Call to read the First Public Editor's Draft and share feedback",
5+
"date": "2021-09-23",
6+
"author": "Kaelig Deloumeau-Prigent",
7+
"url": "https://www.w3.org/community/design-tokens/2021/09/23/call-to-read-the-first-public-editors-draft-and-share-feedback/"
8+
},
9+
{
10+
"id": "upcoming-event-tool-vendor-rountable",
11+
"title": "Upcoming event: design tool vendor roundtable",
12+
"date": "2021-03-09",
13+
"author": "Kaelig Deloumeau-Prigent",
14+
"url": "https://www.w3.org/community/design-tokens/2021/03/09/upcoming-event-design-tool-vendor-roundtable/"
15+
},
16+
{
17+
"id": "status-update-february-2021",
18+
"title": "Status update (February 2021)",
19+
"date": "2021-02-15",
20+
"author": "James Nash",
21+
"url": "https://www.w3.org/community/design-tokens/2021/02/15/status-update-february-2021/"
22+
},
23+
{
24+
"id": "first-editors-draft-shared-with-design-tooling-vendors",
25+
"title": "First Editor's Draft shared with design tooling vendors",
26+
"date": "2021-04-17",
27+
"author": "Kaelig Deloumeau-Prigent",
28+
"url": "https://www.w3.org/community/design-tokens/2021/04/17/first-editors-draft-shared-with/"
29+
},
30+
{
31+
"id": "call-to-implement-the-second-editors-draft-and-share-feedback",
32+
"title": "Call to implement the Second Editors' Draft and share feedback",
33+
"date": "2022-06-14",
34+
"author": "Kaelig Deloumeau-Prigent",
35+
"url": "https://www.w3.org/community/design-tokens/2022/06/14/call-to-implement-the-second-editors-draft-and-share-feedback/"
36+
},
37+
{
38+
"id": "request-for-comments-new-resolver-specification-groups-aliases-updates",
39+
"title": "Request For Comments: new Resolver specification, groups & Aliases updates",
40+
"date": "2025-09-12",
41+
"author": "Kaelig Deloumeau-Prigent",
42+
"url": "https://www.w3.org/community/design-tokens/2025/09/12/request-for-comments-new-resolver-specification-groups-aliases-updates/"
43+
},
44+
{
45+
"id": "design-tokens-specification-reaches-first-stable-version",
46+
"title": "Design Tokens specification reaches first stable version",
47+
"date": "2025-10-28",
48+
"author": "Kaelig Deloumeau-Prigent",
49+
"url": "https://www.w3.org/community/design-tokens/2025/10/28/design-tokens-specification-reaches-first-stable-version/"
50+
}
51+
]

www/src/pages/blog.astro

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,43 @@
11
---
2+
import { getCollection } from 'astro:content';
23
import { getW3FormattedDate, getFormattedDate } from '@/utils/date.utils';
3-
import { posts } from '@/content/posts';
44
import Base from '@/layouts/Base.astro';
55
import Text from '@/components/Text/Text.astro';
66
import Stack from '@/components/Stack/Stack.astro';
77
import { Icon } from 'astro-icon/components';
88
99
const title = 'Blog';
1010
11-
const sortedPosts = posts.sort(
12-
(a, b) => new Date(b.date).valueOf() - new Date(a.date).valueOf(),
13-
);
11+
const posts = await getCollection('posts');
12+
const w3c = await getCollection('w3c');
1413
15-
const formattedPosts = sortedPosts.map((post) => {
16-
const formattedPost = {
17-
title: post.title,
18-
author: post.author,
19-
w3FormattedDate: getW3FormattedDate(post.date),
20-
formattedDate: getFormattedDate(post.date),
21-
url: post.url?.startsWith('http') ? post.url : `/posts/${post.url}/`,
22-
};
23-
return formattedPost;
24-
});
14+
const sortedPosts = [...posts, ...w3c].sort(
15+
(a, b) => b.data.date.getTime() - a.data.date.getTime(),
16+
);
2517
---
2618

2719
<Base title={title}>
2820
<Stack as="ul" gap={12} axis="y" class="blog-list u-list-style:none">
2921
{
30-
formattedPosts.map((post) => (
22+
sortedPosts.map((post) => (
3123
<li>
3224
<Stack as="article" gap={2} class="article">
33-
<a href={post.url} target="_blank">
34-
{post.title}
35-
<Icon
36-
name="external"
37-
aria-label="External link"
38-
role="graphics-symbol img"
39-
/>
40-
</a>
25+
{post.collection === 'w3c' ? (
26+
<a href={post.data.url} target="_blank">
27+
{post.data.title}
28+
<Icon
29+
name="external"
30+
aria-label="External link"
31+
role="graphics-symbol img"
32+
/>
33+
</a>
34+
) : (
35+
<a href={`/blog/${post.id}`}>{post.data.title}</a>
36+
)}
4137
<Text as="p" variant="sm">
42-
<time datetime={post.w3FormattedDate}>{post.formattedDate}</time>
38+
<time datetime={getW3FormattedDate(post.data.date)}>
39+
{getFormattedDate(post.data.date)}
40+
</time>
4341
</Text>
4442
</Stack>
4543
</li>

0 commit comments

Comments
 (0)