test: og url end with slash

This commit is contained in:
radishzzz 2025-03-12 22:09:57 +00:00
parent 79f9765688
commit c97e3d5882
9 changed files with 82 additions and 15 deletions

View 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,
}),
})