Sort tag pages by date instead of name

This commit is contained in:
Cassidy Williams
2023-02-26 22:06:45 -06:00
parent a912bb9ee4
commit 6665edcd48

View File

@@ -33,6 +33,12 @@ export async function getStaticPaths() {
const { tag } = Astro.props;
const { tag: currentTag } = Astro.params;
let sortedPosts = tag.sort(
(a, b) =>
new Date(b.frontmatter.added).valueOf() -
new Date(a.frontmatter.added).valueOf()
);
---
<!DOCTYPE html>
@@ -45,7 +51,7 @@ const { tag: currentTag } = Astro.params;
<h3>Posts tagged with "{currentTag}"</h3>
<ul class="tags-list">
{
tag.map(
sortedPosts.map(
({
url,
frontmatter: { description, slug, title, tags, added: date },