From 60b0bdb264b4a6982f1c91b37423dc5a9e1bcccb Mon Sep 17 00:00:00 2001 From: Ayo Date: Sat, 7 Jan 2023 11:12:04 +0100 Subject: [PATCH] feat: StatusQuote interface (experimental) --- components/status/StatusPreviewCard.vue | 4 +- components/status/StatusPreviewMastodon.vue | 47 ++++++++++++++++++++- composables/status-quote.ts | 10 +++++ 3 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 composables/status-quote.ts diff --git a/components/status/StatusPreviewCard.vue b/components/status/StatusPreviewCard.vue index d8629d78..3a57569f 100644 --- a/components/status/StatusPreviewCard.vue +++ b/components/status/StatusPreviewCard.vue @@ -24,7 +24,9 @@ const providerName = $computed(() => props.card.providerName ? props.card.provid const gitHubCards = $(useFeatureFlag('experimentalGitHubCards')) // checks if title contains a username -const isMastodonLink = props.card.title.match(/@+[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/gi) +const usernames = props.card.title.match(/@+[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/gi) +const isMastodonLink = usernames?.length === 1 && props.card.type === 'link' +const username = isMastodonLink ? usernames[0] : '' // TODO: handle card.type: 'photo' | 'video' | 'rich'; const cardTypeIconMap: Record = { diff --git a/components/status/StatusPreviewMastodon.vue b/components/status/StatusPreviewMastodon.vue index 1f5b14b7..ef3c1ba0 100644 --- a/components/status/StatusPreviewMastodon.vue +++ b/components/status/StatusPreviewMastodon.vue @@ -1,7 +1,8 @@