From cab3ed4ad4f34a0f3e6ba9629c3dc9be31686796 Mon Sep 17 00:00:00 2001 From: Shinigami92 Date: Sat, 10 Dec 2022 23:09:11 +0100 Subject: [PATCH] feat: improve status image quality --- components/status/StatusPreviewCard.vue | 13 +++++-- server/api/og-image.ts | 45 +++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 server/api/og-image.ts diff --git a/components/status/StatusPreviewCard.vue b/components/status/StatusPreviewCard.vue index f4719f68..83fbcc7c 100644 --- a/components/status/StatusPreviewCard.vue +++ b/components/status/StatusPreviewCard.vue @@ -8,11 +8,20 @@ const props = defineProps<{ /** When it is root card in the list, not appear as a child card */ root?: boolean }>() +const image = ref(props.card.image) const alt = $computed(() => `${props.card.title} - ${props.card.title}`) const isSquare = $computed(() => props.smallPictureOnly || props.card.width === props.card.height) const description = $computed(() => props.card.description ? props.card.description : new URL(props.card.url).hostname) // TODO: handle card.type: 'photo' | 'video' | 'rich'; + +$fetch('/api/og-image', { + params: { cardUrl: props.card.url }, +}).then((ogImageUrl) => { + // Only override if ogImageUrl is not empty + if (ogImageUrl) + image.value = ogImageUrl +}).catch(() => {})