diff --git a/components/status/StatusBody.vue b/components/status/StatusBody.vue
index 733f9974..8a41e050 100644
--- a/components/status/StatusBody.vue
+++ b/components/status/StatusBody.vue
@@ -5,15 +5,29 @@ const {
status,
newer,
withAction = true,
+ cleanSharedLink,
} = defineProps<{
status: mastodon.v1.Status | mastodon.v1.StatusEdit
newer?: mastodon.v1.Status
withAction?: boolean
+ cleanSharedLink?: string | false
}>()
const { translation } = useTranslation(status, getLanguageCode())
const emojisObject = useEmojisFallback(() => status.emojis)
+
+/**
+ * example status raw content
+ *
+ *
🔴 trying to code live - come let's talk @elk and #opensource https://www.twitch.tv/ayoayco
+ *
+ *
+ * "I say something about the link first
https://ayco.io
"
+
+ *
+ */
+
const vnode = $computed(() => {
if (!status.content)
return null
@@ -24,7 +38,9 @@ const vnode = $computed(() => {
collapseMentionLink: !!('inReplyToId' in status && status.inReplyToId),
status: 'id' in status ? status : undefined,
inReplyToStatus: newer,
+ cleanSharedLink,
})
+
return vnode
})
diff --git a/components/status/StatusContent.vue b/components/status/StatusContent.vue
index 459f4cd7..01a84355 100644
--- a/components/status/StatusContent.vue
+++ b/components/status/StatusContent.vue
@@ -16,6 +16,10 @@ const filter = $computed(() => filterResult?.filter)
const filterPhrase = $computed(() => filter?.title)
const isFiltered = $computed(() => filterPhrase && (context && context !== 'details' ? filter?.context.includes(context) : false))
+
+const cleanSharedLink = !status.poll
+ && !status.mediaAttachments.length
+ && status.card?.url
@@ -34,7 +38,7 @@ const isFiltered = $computed(() => filterPhrase && (context && context !== 'deta
{{ status.spoilerText }}
-
+
filterPhrase && (context && context !== 'deta
v-if="status.card"
:card="status.card"
:small-picture-only="status.mediaAttachments?.length > 0"
+ :clean-shared-link="cleanSharedLink"
/>
()
const providerName = $computed(() => props.card.providerName ? props.card.providerName : new URL(props.card.url).hostname)
-
const gitHubCards = $(usePreferences('experimentalGitHubCards'))
-
+
diff --git a/components/status/StatusPreviewCardNormal.vue b/components/status/StatusPreviewCardNormal.vue
index 4907630d..96c71113 100644
--- a/components/status/StatusPreviewCardNormal.vue
+++ b/components/status/StatusPreviewCardNormal.vue
@@ -7,6 +7,8 @@ const props = defineProps<{
smallPictureOnly?: boolean
/** When it is root card in the list, not appear as a child card */
root?: boolean
+ /** Defined when the preview card URL matches the last shared link href attribute */
+ cleanSharedLink?: string
}>()
// mastodon's default max og image width
@@ -19,7 +21,7 @@ const isSquare = $computed(() => (
|| Number(props.card.width || 0) < ogImageWidth
|| Number(props.card.height || 0) < ogImageWidth / 2
))
-const providerName = $computed(() => props.card.providerName ? props.card.providerName : new URL(props.card.url).hostname)
+const providerName = $computed(() => props.card.providerName ? `${props.card.providerName} · ${props.cleanSharedLink}` : new URL(props.card.url).hostname)
// TODO: handle card.type: 'photo' | 'video' | 'rich';
const cardTypeIconMap: Record = {
diff --git a/composables/content-parse.ts b/composables/content-parse.ts
index 797323a1..1de903ab 100644
--- a/composables/content-parse.ts
+++ b/composables/content-parse.ts
@@ -16,6 +16,7 @@ export interface ContentParseOptions {
collapseMentionLink?: boolean
status?: mastodon.v1.Status
inReplyToStatus?: mastodon.v1.Status
+ cleanSharedLink?: string | false // this is defined when conditions for cleaning the link are met
}
const sanitizerBasicClasses = filterClasses(/^(h-\S*|p-\S*|u-\S*|dt-\S*|e-\S*|mention|hashtag|ellipsis|invisible)$/u)
@@ -84,6 +85,7 @@ export function parseMastodonHTML(
mentions,
status,
inReplyToStatus,
+ cleanSharedLink,
} = options
if (markdown) {
@@ -127,7 +129,23 @@ export function parseMastodonHTML(
if (collapseMentionLink)
transforms.push(transformCollapseMentions(status, inReplyToStatus))
- return transformSync(parse(html), transforms)
+ const node = parse(html) as Node
+
+ if (cleanSharedLink) {
+ const filteredNode = node.children.filter(child => !!child.children) // remove invisible spans
+ const filteredLength = filteredNode.length
+ const length = filteredNode[filteredLength - 1].children.length
+ const lastChild = filteredNode[filteredLength - 1].children[length - 1]
+ const sharedHref = lastChild.attributes?.href
+ const match = sharedHref === cleanSharedLink
+
+ if (match) {
+ const index = length - 1
+ filteredNode[filteredLength - 1].children.splice(index, 1)
+ }
+ }
+
+ return transformSync(node, transforms)
}
/**