mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-17 20:01:33 +02:00
test: twitter og error
This commit is contained in:
parent
b24d5ba9f5
commit
1cb5e6aafc
8 changed files with 4 additions and 7 deletions
51
src/pages/og/[...image].ts
Normal file
51
src/pages/og/[...image].ts
Normal file
|
@ -0,0 +1,51 @@
|
|||
import { generateDescription } from '@/utils/description'
|
||||
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(post => [
|
||||
post.slug,
|
||||
{
|
||||
title: post.data.title,
|
||||
description: post.data.description || generateDescription(post),
|
||||
},
|
||||
]),
|
||||
)
|
||||
|
||||
// Configure Open Graph image generation route
|
||||
export const { getStaticPaths, GET } = OGImageRoute({
|
||||
param: 'image',
|
||||
pages,
|
||||
getImageOptions: (_path, page) => ({
|
||||
title: page.title,
|
||||
description: page.description,
|
||||
logo: {
|
||||
path: './public/image/og-logo.png', // Required local path and PNG format
|
||||
size: [70],
|
||||
},
|
||||
font: {
|
||||
title: {
|
||||
families: ['Noto Sans SC'], // or Noto Serif SC
|
||||
weight: 'Bold',
|
||||
color: [34, 33, 36],
|
||||
lineHeight: 1.5,
|
||||
},
|
||||
description: {
|
||||
families: ['Noto Sans SC'], // or Noto Serif SC
|
||||
color: [72, 71, 74],
|
||||
lineHeight: 1.5,
|
||||
},
|
||||
},
|
||||
fonts: [
|
||||
'https://raw.githubusercontent.com/notofonts/noto-cjk/main/Sans/SubsetOTF/SC/NotoSansSC-Bold.otf',
|
||||
'https://raw.githubusercontent.com/notofonts/noto-cjk/main/Sans/SubsetOTF/SC/NotoSansSC-Regular.otf',
|
||||
// 'https://raw.githubusercontent.com/notofonts/noto-cjk/main/Serif/SubsetOTF/SC/NotoSerifSC-Bold.otf',
|
||||
// 'https://raw.githubusercontent.com/notofonts/noto-cjk/main/Serif/SubsetOTF/SC/NotoSerifSC-Regular.otf',
|
||||
],
|
||||
bgGradient: [[242, 241, 245]],
|
||||
}),
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue