Clean up tags page more
This commit is contained in:
@@ -3,6 +3,7 @@ import BaseHead from '../components/BaseHead.astro';
|
|||||||
import Header from '../components/Header.astro';
|
import Header from '../components/Header.astro';
|
||||||
import Footer from '../components/Footer.astro';
|
import Footer from '../components/Footer.astro';
|
||||||
import Post from '../components/Post.astro';
|
import Post from '../components/Post.astro';
|
||||||
|
import ColorScript from '../components/ColorScript.astro';
|
||||||
|
|
||||||
import { SITE_TITLE, SITE_DESCRIPTION } from '../config';
|
import { SITE_TITLE, SITE_DESCRIPTION } from '../config';
|
||||||
|
|
||||||
@@ -42,5 +43,6 @@ const posts = (await Astro.glob('../posts/*.{md,mdx}')).sort(
|
|||||||
</content>
|
</content>
|
||||||
<Footer />
|
<Footer />
|
||||||
</main>
|
</main>
|
||||||
|
<ColorScript />
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -6,22 +6,6 @@ import Post from '../../components/Post.astro';
|
|||||||
|
|
||||||
import { SITE_TITLE, SITE_DESCRIPTION } from '../../config';
|
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
|
// Credit to @rachsmithcodes for helping out my lil ol brain
|
||||||
export async function getStaticPaths() {
|
export async function getStaticPaths() {
|
||||||
let posts = await Astro.glob(`../../posts/*.md`);
|
let posts = await Astro.glob(`../../posts/*.md`);
|
||||||
@@ -38,8 +22,6 @@ export async function getStaticPaths() {
|
|||||||
return allTags;
|
return allTags;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
console.log(tags)
|
|
||||||
|
|
||||||
return Object.keys(tags).map((t) => {
|
return Object.keys(tags).map((t) => {
|
||||||
return ({
|
return ({
|
||||||
params: { tag: t },
|
params: { tag: t },
|
||||||
@@ -49,6 +31,7 @@ export async function getStaticPaths() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { tag } = Astro.props;
|
const { tag } = Astro.props;
|
||||||
|
const { tag: currentTag } = Astro.params;
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -73,6 +56,7 @@ const { tag } = Astro.props;
|
|||||||
<Header />
|
<Header />
|
||||||
<main>
|
<main>
|
||||||
<content>
|
<content>
|
||||||
|
<h3>Posts tagged with "{currentTag}"</h3>
|
||||||
<ul>
|
<ul>
|
||||||
{tag.map(
|
{tag.map(
|
||||||
({url, frontmatter: { description, slug, title, tags, added: date }}) => (
|
({url, frontmatter: { description, slug, title, tags, added: date }}) => (
|
||||||
|
|||||||
Reference in New Issue
Block a user