mirror of
https://github.com/saicaca/fuwari.git
synced 2026-01-11 06:42:53 +01:00
fix(blog): restore prev/next post navigation buttons (#346)
Co-authored-by: 0bipinnata0 <0bipinnata0@users.noreply.github.com>
This commit is contained in:
@@ -13,11 +13,10 @@ import PostMetadata from '../../components/PostMeta.astro'
|
||||
import ImageWrapper from '../../components/misc/ImageWrapper.astro'
|
||||
import { profileConfig, siteConfig } from '../../config'
|
||||
import { formatDateToYYYYMMDD } from '../../utils/date-utils'
|
||||
import { getSortedPosts } from '@utils/content-utils'
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const blogEntries = await getCollection('posts', ({ data }) => {
|
||||
return import.meta.env.PROD ? data.draft !== true : true
|
||||
})
|
||||
const blogEntries = await getSortedPosts();
|
||||
return blogEntries.map(entry => ({
|
||||
params: { slug: entry.slug },
|
||||
props: { entry },
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
import { getCollection } from 'astro:content'
|
||||
import type { BlogPostData } from '@/types/config'
|
||||
import I18nKey from '@i18n/i18nKey'
|
||||
import { i18n } from '@i18n/translation'
|
||||
|
||||
export async function getSortedPosts(): Promise<
|
||||
{ body: string, data: BlogPostData; slug: string }[]
|
||||
> {
|
||||
export async function getSortedPosts() {
|
||||
const allBlogPosts = (await getCollection('posts', ({ data }) => {
|
||||
return import.meta.env.PROD ? data.draft !== true : true
|
||||
})) as unknown as { body: string, data: BlogPostData; slug: string }[]
|
||||
}))
|
||||
|
||||
const sorted = allBlogPosts.sort(
|
||||
(a: { data: BlogPostData }, b: { data: BlogPostData }) => {
|
||||
(a, b) => {
|
||||
const dateA = new Date(a.data.published)
|
||||
const dateB = new Date(b.data.published)
|
||||
return dateA > dateB ? -1 : 1
|
||||
|
||||
Reference in New Issue
Block a user