Skip to content

Commit ab9d8c5

Browse files
authored
Merge pull request #303 from maxulysse/gix_legacy
2 parents 3a5acb3 + da37b42 commit ab9d8c5

7 files changed

Lines changed: 67 additions & 57 deletions

File tree

.github/dependabot.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ updates:
55
schedule:
66
interval: "weekly"
77
open-pull-requests-limit: 10
8-
ignore:
9-
- dependency-name: "typescript"
10-
update-types:
11-
- "version-update:semver-major"
128
labels:
139
- "dependencies"
1410
- "security"

src/content.config.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { defineCollection, z } from "astro:content";
2+
import { glob } from "astro/loaders";
3+
4+
const blogCollection = defineCollection({
5+
loader: glob({ pattern: "**/*.{md,mdx}", base: "./src/content/blog" }),
6+
schema: z.object({
7+
title: z.string(),
8+
description: z.string().optional(),
9+
date: z.coerce.date(),
10+
author: z.string().optional().default("maxulysse"),
11+
tags: z.array(z.string()).optional(),
12+
image: z
13+
.object({
14+
path: z.string(),
15+
})
16+
.optional(),
17+
draft: z.boolean().optional().default(false),
18+
}),
19+
});
20+
21+
const presentationsCollection = defineCollection({
22+
loader: glob({
23+
pattern: "**/*.{md,mdx}",
24+
base: "./src/content/presentations",
25+
}),
26+
schema: z.object({
27+
title: z.string(),
28+
description: z.string().optional(),
29+
date: z.coerce.date(),
30+
author: z.string().optional().default("maxulysse"),
31+
tags: z.array(z.string()).optional(),
32+
image: z
33+
.object({
34+
path: z.string(),
35+
})
36+
.optional(),
37+
duration: z.string().optional(),
38+
location: z
39+
.object({
40+
city: z.string().optional(),
41+
country: z.string().optional(),
42+
})
43+
.optional(),
44+
redirects: z.array(z.string()).optional(),
45+
}),
46+
});
47+
48+
export const collections = {
49+
blog: blogCollection,
50+
presentations: presentationsCollection,
51+
};

src/content/config.ts

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

src/pages/[...slideslug].astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export async function getStaticPaths() {
1010
const paths = [];
1111
1212
for (const presentation of presentations) {
13-
const slug = normalizePath(presentation.slug);
13+
const slug = normalizePath(presentation.id);
1414
const redirects = presentation.data.redirects || [];
1515
1616
// Main path: /folder-name/
@@ -39,7 +39,7 @@ export async function getStaticPaths() {
3939
}
4040
4141
const { presentation } = Astro.props;
42-
const slidesContent = presentation.body;
42+
const slidesContent = presentation.body || "";
4343
const pageTitle = presentation.data.title;
4444
---
4545

src/pages/blog/[...slug].astro

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
2-
import { getCollection } from "astro:content";
2+
import { getCollection, render } from "astro:content";
33
import PostLayout from "../../layouts/PostLayout.astro";
44
55
export async function getStaticPaths() {
66
const blogEntries = await getCollection("blog");
77
return blogEntries.map((entry) => ({
8-
params: { slug: entry.slug },
8+
params: { slug: entry.id },
99
props: { entry },
1010
}));
1111
}
@@ -16,7 +16,7 @@ interface Props {
1616
1717
const { slug } = Astro.params;
1818
const allEntries = await getCollection("blog");
19-
const entry = allEntries.find((e) => e.slug === slug);
19+
const entry = allEntries.find((e) => e.id === slug);
2020
2121
if (!entry) {
2222
return Astro.redirect("/");
@@ -32,7 +32,9 @@ const normalizeDate = (value: unknown) => {
3232
};
3333
3434
const findSlideRedirect = async (postEntry: any) => {
35-
const tags = (postEntry.data.tags || []).map((tag: string) => tag.toLowerCase());
35+
const tags = (postEntry.data.tags || []).map((tag: string) =>
36+
tag.toLowerCase(),
37+
);
3638
if (!tags.includes("presentation")) return null;
3739
3840
const presentations = await getCollection("presentations");
@@ -45,7 +47,7 @@ const findSlideRedirect = async (postEntry: any) => {
4547
4648
if (slideDate === targetDate && slideTitle === targetTitle) {
4749
const redirects = presentation.data.redirects || [];
48-
const redirect = redirects[0] || presentation.slug;
50+
const redirect = redirects[0] || presentation.id;
4951
const normalized = redirect.replace(/^\/+/, "");
5052
return `/${normalized}/`;
5153
}
@@ -59,7 +61,7 @@ if (slideRedirect) {
5961
return Astro.redirect(slideRedirect, 302);
6062
}
6163
62-
const { Content } = await entry.render();
64+
const { Content } = await render(entry);
6365
---
6466

6567
<PostLayout

src/pages/blog/page/[page].astro

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@ if (currentPage === 1) {
5151
)}
5252
<div class="card-body">
5353
<h5 class="card-title">
54-
<a href={`/blog/${post.slug}/`}>
54+
<a href={`/blog/${post.id}/`}>
5555
{post.data.title}
5656
</a>
5757
</h5>
5858
<p class="card-text">
5959
{post.data.description ||
60-
post.body.substring(0, 150)}
60+
post.body?.substring(0, 150) ||
61+
""}
6162
</p>
6263
</div>
6364
<div class="card-footer">

src/pages/index.astro

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ const totalPages = Math.ceil(sortedPosts.length / postsPerPage);
2929
)}
3030
<div class="card-body">
3131
<h5 class="card-title">
32-
<a href={`/blog/${post.slug}/`}>
32+
<a href={`/blog/${post.id}/`}>
3333
{post.data.title}
3434
</a>
3535
</h5>
3636
<p class="card-text">
3737
{post.data.description ||
38-
post.body.substring(0, 150)}
38+
post.body?.substring(0, 150) ||
39+
""}
3940
</p>
4041
</div>
4142
<div class="card-footer">

0 commit comments

Comments
 (0)