forked from Mirrors/elk
fix fallbackUrl
This commit is contained in:
parent
49290b7386
commit
5e717cac03
2 changed files with 5 additions and 2 deletions
|
@ -12,7 +12,9 @@ const cardImage = $computed(() => props.card.image)
|
||||||
const alt = $computed(() => `${props.card.title} - ${props.card.title}`)
|
const alt = $computed(() => `${props.card.title} - ${props.card.title}`)
|
||||||
const isSquare = $computed(() => props.smallPictureOnly || props.card.width === props.card.height)
|
const isSquare = $computed(() => props.smallPictureOnly || props.card.width === props.card.height)
|
||||||
const providerName = $computed(() => props.card.providerName ? props.card.providerName : new URL(props.card.url).hostname)
|
const providerName = $computed(() => props.card.providerName ? props.card.providerName : new URL(props.card.url).hostname)
|
||||||
const imageSrcset = $computed(() => props.card.image ? `${props.card.image}, /api/og-image/${encodeURIComponent(props.card.url)} 2x` : '')
|
const imageSrcset = $computed(() => props.card.image
|
||||||
|
? `${props.card.image}, /api/og-image/${encodeURIComponent(props.card.url)}?fallbackUrl=${encodeURIComponent(props.card.image)} 2x`
|
||||||
|
: '')
|
||||||
|
|
||||||
// TODO: handle card.type: 'photo' | 'video' | 'rich';
|
// TODO: handle card.type: 'photo' | 'video' | 'rich';
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -37,6 +37,7 @@ async function resolveOgImageUrlManually(cardUrl: string): Promise<string> {
|
||||||
|
|
||||||
export default defineEventHandler(async (event) => {
|
export default defineEventHandler(async (event) => {
|
||||||
const { url } = getRouterParams(event)
|
const { url } = getRouterParams(event)
|
||||||
|
const { fallbackUrl } = getQuery(event)
|
||||||
|
|
||||||
const cardUrl = decodeURIComponent(url)
|
const cardUrl = decodeURIComponent(url)
|
||||||
|
|
||||||
|
@ -77,7 +78,7 @@ export default defineEventHandler(async (event) => {
|
||||||
|
|
||||||
if (!ogImageUrl) {
|
if (!ogImageUrl) {
|
||||||
// If nothing helped, set cardUrl as default
|
// If nothing helped, set cardUrl as default
|
||||||
ogImageUrl = cardUrl
|
ogImageUrl = decodeURIComponent(fallbackUrl as string)
|
||||||
}
|
}
|
||||||
|
|
||||||
await sendRedirect(event, ogImageUrl)
|
await sendRedirect(event, ogImageUrl)
|
||||||
|
|
Loading…
Reference in a new issue