Fix updated posts logic
This commit is contained in:
@@ -3,16 +3,15 @@ import Post from "../components/Post.astro";
|
|||||||
|
|
||||||
const { allPosts } = Astro.props;
|
const { allPosts } = Astro.props;
|
||||||
|
|
||||||
// TODO: account for recently updated posts, too
|
//.sort(() => 0.5 - Math.random()).slice(0, 3);
|
||||||
|
|
||||||
let posts = allPosts
|
let posts = allPosts
|
||||||
.sort(
|
.sort(
|
||||||
(a, b) =>
|
(a, b) =>
|
||||||
new Date(b.frontmatter.added).valueOf() -
|
new Date(b.frontmatter.updated || b.frontmatter.added).valueOf() -
|
||||||
new Date(a.frontmatter.added).valueOf()
|
new Date(a.frontmatter.updated || a.frontmatter.added).valueOf()
|
||||||
)
|
)
|
||||||
.slice(0, 5);
|
.slice(0, 5);
|
||||||
|
|
||||||
//.sort(() => 0.5 - Math.random()).slice(0, 3);
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<content>
|
<content>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const posts = await Astro.glob("../posts/*.md");
|
|||||||
const tags = getTags(posts);
|
const tags = getTags(posts);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
content: { title, description, added, updatedDate, heroImage },
|
content: { title, description, added, updated, heroImage },
|
||||||
} = Astro.props;
|
} = Astro.props;
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -25,9 +25,9 @@ const {
|
|||||||
<h1 class="article-title">{title}</h1>
|
<h1 class="article-title">{title}</h1>
|
||||||
{added && <time>{added}</time>}
|
{added && <time>{added}</time>}
|
||||||
{
|
{
|
||||||
updatedDate && (
|
updated && (
|
||||||
<div>
|
<div>
|
||||||
Last updated on <time>{updatedDate}</time>
|
Last updated on <time>{updated}</time>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user