Skip to content

Commit f0f4a45

Browse files
committed
fix: tag pages.
1 parent d3d39a1 commit f0f4a45

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/content/posts/seo/getting-google-my-business-cid-codes-quickly.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: 'Getting Google My Business CID Codes, Quickly.'
33
date: '2021-03-06'
4-
tags: ['SEO']
4+
tags: ['SEO', 'JavaScript']
55
draft: false
66
featuredImage: blog/seo-google-cid-script-executed.webp
77
summary:

src/content/posts/wordpress/scrape-and-debug-a-wordpress-plugin.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: 'Scrape & Debug: A WordPress Plugin'
33
date: '2020-08-02'
4-
tags: ['WordPress']
4+
tags: ['WordPress', 'JavaScript', 'Legacy', 'SEO']
55
draft: false
66
featuredImage: blog/wordpress-scrape-and-debug.webp
77
summary:

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,23 @@ import type { CollectionEntry } from 'astro:content';
66
77
export async function getStaticPaths() {
88
const posts = await getCollection('posts');
9+
910
const tags = new Set<string>(
10-
posts.flatMap((post: CollectionEntry<'posts'>) => post.data.tags || [])
11+
posts.flatMap((post: CollectionEntry<'posts'>) =>
12+
(post.data.tags || []).map((t: string) => t.toLowerCase())
13+
)
1114
);
1215
1316
return Array.from(tags).map((tag) => ({
1417
params: { tag: tag.toLowerCase() },
1518
props: {
1619
tag: tag.toLowerCase(),
17-
posts: posts.filter((post: CollectionEntry<'posts'>) =>
18-
post.data.tags?.map((t: string) => t.toLowerCase()).includes(tag.toLowerCase())
19-
) as CollectionEntry<'posts'>[],
20+
posts: posts.filter((post: CollectionEntry<'posts'>) => {
21+
const postTags = (post.data.tags || []).map((t: string) => t.toLowerCase());
22+
const match = postTags.includes(tag.toLowerCase());
23+
24+
return match;
25+
}) as CollectionEntry<'posts'>[],
2026
},
2127
}));
2228
}

0 commit comments

Comments
 (0)