Skip to content

Commit e6cc6ac

Browse files
committed
fix: order blogposts
1 parent 2d759f9 commit e6cc6ac

File tree

5 files changed

+10
-19
lines changed

5 files changed

+10
-19
lines changed

app/[lang]/opengraph-image/route.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ export const size = {
1010

1111
export async function GET(req: NextRequest) {
1212
try {
13-
// Get the language from the URL
14-
const lang = req.nextUrl.pathname.split('/')[1] || 'en'
15-
1613
// Get the base URL from the request
1714
const protocol = req.headers.get('x-forwarded-proto') || 'http'
1815
const host = req.headers.get('host') || 'localhost:3000'
@@ -45,6 +42,7 @@ export async function GET(req: NextRequest) {
4542
backgroundColor: '#000',
4643
}}
4744
>
45+
{/* eslint-disable-next-line @next/next/no-img-element */}
4846
<img
4947
src={dataUrl}
5048
alt=""

app/_components/blog.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@ export async function generateMetadata() {
1313
export const Blog: FC<{ lang: string }> = async ({ lang }) => {
1414
const pageMap = (await getPageMap(`/${lang}/blog`)) as unknown as MdxFile[]
1515

16-
return pageMap.map(page => {
17-
if (page.name === 'index') return
16+
const sortedPages = pageMap
17+
.filter(page => page.name !== 'index')
18+
.sort((a, b) => {
19+
const dateA = new Date(a.frontMatter?.date).getTime()
20+
const dateB = new Date(b.frontMatter?.date).getTime()
21+
return dateB - dateA
22+
})
1823

24+
return sortedPages.map(page => {
1925
const { title, description, date } = page.frontMatter!
2026

2127
return (

app/api/og/route.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export async function GET(req: NextRequest) {
4949
backgroundColor: '#000',
5050
}}
5151
>
52+
{/* eslint-disable-next-line @next/next/no-img-element */}
5253
<img
5354
src={dataUrl}
5455
alt=""

content/en/patterns/navigation/checkbox.mdx

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)