updated link sharing

This commit is contained in:
2026-03-20 20:31:38 +00:00
parent bc25fabd40
commit 0463275ba5
2 changed files with 14 additions and 9 deletions

View File

@@ -41,7 +41,7 @@
<v-row justify="center" class="mt-12 pb-10"> <v-row justify="center" class="mt-12 pb-10">
<v-btn <v-btn
class="px=8 print-btn" class="px-8 print-btn"
size="large" size="large"
elevation="0" elevation="0"
@click="printRecipe" @click="printRecipe"
@@ -132,9 +132,12 @@ const printRecipe = () => {
} }
const shareRecipe = async () => { const shareRecipe = async () => {
const shareUrl = props.recipe.id if (!props.recipe?.id) {
? `${window.location.origin}/recipe/${props.recipe.id}` alert("Please save this recipe to your collection first to generate a shareable link!");
: window.location.href; return;
}
const shareUrl = `${window.location.origin}/recipe/${props.recipe.id}`;
const shareData = { const shareData = {
title: props.recipe.title, title: props.recipe.title,
@@ -144,14 +147,13 @@ const shareRecipe = async () => {
try { try {
if (navigator.share) { if (navigator.share) {
await navigator.share(shareData) await navigator.share(shareData);
triggerShareSuccess()
} else { } else {
await navigator.clipboard.writeText(shareUrl) await navigator.clipboard.writeText(shareUrl);
triggerShareSuccess()
} }
triggerShareSuccess();
} catch (err) { } catch (err) {
console.error('Error sharing:', err) if (err.name !== 'AbortError') console.error('Error sharing:', err);
} }
} }

View File

@@ -9,6 +9,9 @@
<script setup> <script setup>
import { computed } from 'vue' import { computed } from 'vue'
definePageMeta({
auth: false
})
const route = useRoute(); const route = useRoute();
const config = useRuntimeConfig(); const config = useRuntimeConfig();