mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-20 18:24:45 +00:00
Add secureUrl and type to OG image metadata
This commit is contained in:
parent
9313eb7f29
commit
260f75abe8
1 changed files with 17 additions and 12 deletions
|
|
@ -19,7 +19,9 @@ const truncate = (text: string, max: number) =>
|
||||||
text.length <= max ? text : `${text.slice(0, max - 1).trimEnd()}…`
|
text.length <= max ? text : `${text.slice(0, max - 1).trimEnd()}…`
|
||||||
|
|
||||||
const toAbsoluteUrl = (url: string, siteUrl: string) =>
|
const toAbsoluteUrl = (url: string, siteUrl: string) =>
|
||||||
/^https?:\/\//i.test(url) ? url : `${stripTrailingSlash(siteUrl)}${url.startsWith('/') ? '' : '/'}${url}`
|
/^https?:\/\//i.test(url)
|
||||||
|
? url
|
||||||
|
: `${stripTrailingSlash(siteUrl)}${url.startsWith('/') ? '' : '/'}${url}`
|
||||||
|
|
||||||
export async function generateStaticParams() {
|
export async function generateStaticParams() {
|
||||||
const payload = await getDocuments('petition')
|
const payload = await getDocuments('petition')
|
||||||
|
|
@ -67,17 +69,20 @@ export async function generateMetadata({
|
||||||
petition.title,
|
petition.title,
|
||||||
]
|
]
|
||||||
|
|
||||||
const ogImages =
|
const imageUrl = image?.url ? toAbsoluteUrl(image.url, siteUrl) : undefined
|
||||||
image?.url
|
|
||||||
? [
|
const ogImages = imageUrl
|
||||||
{
|
? [
|
||||||
url: toAbsoluteUrl(image.url, siteUrl),
|
{
|
||||||
width: image.width ?? undefined,
|
url: imageUrl,
|
||||||
height: image.height ?? undefined,
|
secureUrl: imageUrl,
|
||||||
alt: image.alt,
|
width: image.width ?? undefined,
|
||||||
},
|
height: image.height ?? undefined,
|
||||||
]
|
alt: image.alt,
|
||||||
: []
|
type: image.mimeType ?? undefined,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title,
|
title,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue