mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-17 12:01:33 +02:00
test: og url end with slash
This commit is contained in:
parent
79f9765688
commit
c97e3d5882
9 changed files with 82 additions and 15 deletions
28
src/pages/og/[...route].ts
Normal file
28
src/pages/og/[...route].ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
import { OGImageRoute } from 'astro-og-canvas'
|
||||
import { getCollection } from 'astro:content'
|
||||
|
||||
// eslint-disable-next-line antfu/no-top-level-await
|
||||
const blogEntries = await getCollection('posts')
|
||||
|
||||
// Convert to page data objects
|
||||
const pages = Object.fromEntries(
|
||||
blogEntries.map(({ slug, data }) => [
|
||||
data.abbrlink || slug, // Prioritize using abbrlink instead of slug
|
||||
{
|
||||
title: data.title,
|
||||
description: data.description || '',
|
||||
},
|
||||
]),
|
||||
)
|
||||
|
||||
// Configure Open Graph image generation route
|
||||
export const { getStaticPaths, GET } = OGImageRoute({
|
||||
param: 'route',
|
||||
pages,
|
||||
getImageOptions: (_path, page) => ({
|
||||
title: page.title,
|
||||
description: page.description,
|
||||
border: { width: 10 },
|
||||
padding: 40,
|
||||
}),
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue