How to make a post list page with last updated time? #2839
-
I have read the docs, createContentLoader is a good way, and I found this code in docs: transform(rawData) {
// map, sort, or filter the raw data as you wish.
// the final result is what will be shipped to the client.
return rawData.sort((a, b) => {
return +new Date(b.frontmatter.date) - +new Date(a.frontmatter.date)
}).map((page) => {
page.src // raw markdown source
page.html // rendered full page HTML
page.excerpt // rendered excerpt HTML (content above first `---`)
return {/* ... */}
})
} but sometimes we don't manually write date in frontmatter,is there some way to get all posts' last updated time just like runtime API? |
Beta Was this translation helpful? Give feedback.
Answered by
brc-dd
Aug 24, 2023
Replies: 1 comment 1 reply
-
For the moment, you can copy getGitTimestamp function from our source code and use it inside transform. We can expose that if there is much demand. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
StreakingMan
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For the moment, you can copy getGitTimestamp function from our source code and use it inside transform. We can expose that if there is much demand.