From 9bdfd71b0abcf1acd524301b96ba80020abb1dee Mon Sep 17 00:00:00 2001 From: Ayo Date: Wed, 11 Jan 2023 17:44:40 +0100 Subject: [PATCH] feat: remove from content if matches preview URL --- components/status/StatusBody.vue | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/components/status/StatusBody.vue b/components/status/StatusBody.vue index d91b5ad9..a4f10821 100644 --- a/components/status/StatusBody.vue +++ b/components/status/StatusBody.vue @@ -21,6 +21,16 @@ const vnode = $computed(() => { }) return vnode }) + +// remove link at the end of content if matches preview card URL +const previewCardURL = (status as mastodon.v1.Status).card?.url +if (vnode?.children !== null) { + const contentChildren = vnode?.children[0].children + const contentLastChild = contentChildren[contentChildren.length - 1] + const matchesPreviewURL = contentLastChild.type === 'a' && contentLastChild.props?.href === previewCardURL + if (matchesPreviewURL) + contentChildren.pop() +}