From 1e4de5bc0f0bebef1ac7068b5f16173e83468ea4 Mon Sep 17 00:00:00 2001 From: joe-irving Date: Sun, 9 Jun 2024 16:14:33 +0100 Subject: [PATCH] add sources to share urls --- components/ShareTile.vue | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/components/ShareTile.vue b/components/ShareTile.vue index f90a46b..95aa15c 100644 --- a/components/ShareTile.vue +++ b/components/ShareTile.vue @@ -23,16 +23,22 @@ const props = defineProps({ } }) +const sourcedUrl = (source: string) => { + const url = new URL(props.url) + url.searchParams.set('source', source) + return url.toString() +} + const shareButtonLinks = ref({ facebook: `https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent( - props.url - )}`, + sourcedUrl('facebook') + )}&src=sdkpreparse`, twitter: `https://twitter.com/intent/tweet?text=${encodeURIComponent( props.tweet || props.description || '' - )}&url=${encodeURIComponent(props.url)}`, + )}&url=${encodeURIComponent(sourcedUrl('twitter'))}`, whatsapp: `https://wa.me/?text=${encodeURIComponent( props.whatsapp || props.description || '' - )}+${props.url}` + )}+${sourcedUrl('whatsapp')}` }) const isCopied = ref(false)