Update posts by tag, fix ul styling
This commit is contained in:
@@ -4,29 +4,14 @@ import Header from "../components/Header.astro";
|
||||
import Footer from "../components/Footer.astro";
|
||||
import HomePosts from "../components/HomePosts.astro";
|
||||
import ColorScript from "../components/ColorScript.astro";
|
||||
import Tags from "../components/Tags.astro";
|
||||
import { SITE_TITLE, SITE_DESCRIPTION } from "../config";
|
||||
import { Content as About } from "./about.md";
|
||||
import getTags from "../scripts/getTags";
|
||||
|
||||
const posts = await Astro.glob("../posts/*.md");
|
||||
|
||||
// Get tags from all posts
|
||||
const getTags = posts
|
||||
.map((post) => {
|
||||
const postTags = post.frontmatter.tags;
|
||||
let allTags = [];
|
||||
|
||||
if (postTags.length > 0) {
|
||||
postTags.forEach((tag) => {
|
||||
if (allTags.indexOf(tag) === -1) {
|
||||
allTags.push(tag);
|
||||
}
|
||||
});
|
||||
}
|
||||
return allTags;
|
||||
})
|
||||
.flat(1);
|
||||
// Make the tags unique
|
||||
let tags = [...new Set(getTags)];
|
||||
const tags = getTags(posts);
|
||||
---
|
||||
|
||||
<!DOCTYPE html>
|
||||
@@ -40,20 +25,7 @@ let tags = [...new Set(getTags)];
|
||||
<h3>Here's my most recent posts</h3>
|
||||
<HomePosts allPosts={posts} />
|
||||
|
||||
<h3>View posts by tag</h3>
|
||||
<p>
|
||||
{
|
||||
tags &&
|
||||
tags.map((tag) => (
|
||||
<>
|
||||
<a class="tag" href={`/tag/${tag}`}>
|
||||
#{tag}
|
||||
</a>
|
||||
{` `}
|
||||
</>
|
||||
))
|
||||
}
|
||||
</p>
|
||||
<Tags tags={tags} />
|
||||
</main>
|
||||
<Footer />
|
||||
<ColorScript />
|
||||
|
||||
Reference in New Issue
Block a user