Skip to content

Commit 7ef3833

Browse files
committed
Replace entry slug with id
1 parent a2e5cb9 commit 7ef3833

File tree

8 files changed

+12
-14
lines changed

8 files changed

+12
-14
lines changed

src/components/pages/blog/BlogListEntry.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { post } = Astro.props;
55
---
66

77
<article
8-
data-category={post.slug.split('/')[0]}
8+
data-category={post.id.split('/')[0]}
99
class="font-light"
1010
aria-hidden="false"
1111
>

src/lib/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import MarkdownIt from 'markdown-it';
33
export function generatePathFromPost(post, attachBlog = true) {
44
const postDate = new Date(post.data.date);
55
return `/${attachBlog ? 'blog/' : ''}${
6-
post.slug.split('/')[0] +
6+
post.id.split('/')[0] +
77
'/' +
88
postDate.getFullYear() +
99
'/' +
10-
post.slug.split('/').pop().split('_').pop()
10+
post.id.split('/').pop().split('_').pop()
1111
}`;
1212
}
1313

src/pages/blog/[category].astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export async function getStaticPaths() {
1010
const blogEntries = await getCollection('blog');
1111
1212
const filteredEntries = blogEntries.reduce((groups, entry) => {
13-
const category = entry.slug.split('/')[0];
13+
const category = entry.id.split('/')[0];
1414
if (!groups[category]) {
1515
groups[category] = {
1616
params: {

src/pages/blog/[category]/[year].astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export async function getStaticPaths() {
1010
const blogEntries = await getCollection('blog');
1111
1212
const filteredEntries = blogEntries.reduce((groups, entry) => {
13-
const category = entry.slug.split('/')[0];
13+
const category = entry.id.split('/')[0];
1414
const postYear = new Date(entry.data.date).getFullYear();
1515
if (!groups[category + postYear]) {
1616
groups[category + postYear] = {

src/pages/blog/[category]/[year]/[id].astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ export async function getStaticPaths() {
88
const blogEntries = await getCollection('blog');
99
return blogEntries.map((entry) => ({
1010
params: {
11-
category: entry.slug.split('/')[0],
11+
category: entry.id.split('/')[0],
1212
year: new Date(entry.data.date).getFullYear(),
13-
id: entry.slug.split('/').pop().split('_').pop(),
13+
id: entry.id.split('/').pop().split('_').pop(),
1414
},
1515
props: { entry },
1616
}));

src/pages/community.astro

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ import nixosFoundationLogo from '../assets/image/nixos-foundation-logo.svg';
422422
teams.map((team) => (
423423
<li class="flex grow basis-72 flex-col items-center gap-2 text-center text-white md:items-start md:text-left [&>a]:inline-block">
424424
<img
425-
src={`/images/teams/${team.slug.split('_')[1]}.svg`}
425+
src={`/images/teams/${team.id.split('_')[1]}.svg`}
426426
alt={`${team.data.name} Logo`}
427427
class="h-24"
428428
/>
@@ -432,7 +432,7 @@ import nixosFoundationLogo from '../assets/image/nixos-foundation-logo.svg';
432432
</p>
433433
<Button
434434
color="green"
435-
href={'/community/teams/' + team.slug.split('_')[1]}
435+
href={'/community/teams/' + team.id.split('_')[1]}
436436
>
437437
Read more
438438
</Button>
@@ -461,9 +461,7 @@ import nixosFoundationLogo from '../assets/image/nixos-foundation-logo.svg';
461461
<ul class="mx-auto mt-2 list-disc pl-8 md:w-72 md:pl-10">
462462
{
463463
teams
464-
.filter(
465-
(team) => team.slug.split('_')[1] === 'foundation-board',
466-
)[0]
464+
.find((team) => team.id.split('_')[1] === 'foundation-board')
467465
.data.members.map((member) => (
468466
<li class="mb-1">
469467
{member.name}

src/pages/community/teams/[...slug].astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Layout from '../../../layouts/Layout.astro';
99
export async function getStaticPaths() {
1010
const teamEntries = await getCollection('teams');
1111
return teamEntries.map((entry) => ({
12-
params: { slug: entry.slug.split('_')[1] },
12+
params: { slug: entry.id.split('_')[1] },
1313
props: { entry },
1414
}));
1515
}

src/pages/index.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ posts
2020
return dateA > dateB ? -1 : 1;
2121
})
2222
.filter((p) => {
23-
return p.slug.split('/')?.[0] === 'announcements';
23+
return p.id.split('/')?.[0] === 'announcements';
2424
})
2525
.reverse();
2626
---

0 commit comments

Comments
 (0)