Clean up tags page more

This commit is contained in:
Cassidy Williams
2022-09-01 16:12:40 -05:00
parent 9618162bae
commit 725b93fd79
2 changed files with 4 additions and 18 deletions

View File

@@ -3,6 +3,7 @@ import BaseHead from '../components/BaseHead.astro';
import Header from '../components/Header.astro';
import Footer from '../components/Footer.astro';
import Post from '../components/Post.astro';
import ColorScript from '../components/ColorScript.astro';
import { SITE_TITLE, SITE_DESCRIPTION } from '../config';
@@ -42,5 +43,6 @@ const posts = (await Astro.glob('../posts/*.{md,mdx}')).sort(
</content>
<Footer />
</main>
<ColorScript />
</body>
</html>

View File

@@ -6,22 +6,6 @@ import Post from '../../components/Post.astro';
import { SITE_TITLE, SITE_DESCRIPTION } from '../../config';
// @rachsmithcodes wrote this
function postTags(posts) {
return posts.reduce((allTags, post) => {
const postTags = post.frontmatter.tags;
if (postTags) {
postTags.forEach((tag) => {
if (!allTags[tag]) {
allTags[tag] = [];
}
allTags[tag].push(post);
});
}
return allTags;
}, {});
}
// Credit to @rachsmithcodes for helping out my lil ol brain
export async function getStaticPaths() {
let posts = await Astro.glob(`../../posts/*.md`);
@@ -38,8 +22,6 @@ export async function getStaticPaths() {
return allTags;
}, {});
console.log(tags)
return Object.keys(tags).map((t) => {
return ({
params: { tag: t },
@@ -49,6 +31,7 @@ export async function getStaticPaths() {
}
const { tag } = Astro.props;
const { tag: currentTag } = Astro.params;
---
@@ -73,6 +56,7 @@ const { tag } = Astro.props;
<Header />
<main>
<content>
<h3>Posts tagged with "{currentTag}"</h3>
<ul>
{tag.map(
({url, frontmatter: { description, slug, title, tags, added: date }}) => (