diff --git a/src/components/ShareSticky.vue b/src/components/ShareSticky.vue index dacae84..c6661fd 100644 --- a/src/components/ShareSticky.vue +++ b/src/components/ShareSticky.vue @@ -25,6 +25,12 @@ +
  • + + + +
  • +
  • @@ -79,6 +85,14 @@ + + + + { } const copied = ref(false) -const mobileOpen = ref(false) -const encodedUrl = computed(() => encodeURIComponent(props.url)) -const twitterUrl = computed(() => `https://twitter.com/intent/tweet?url=${encodedUrl.value}`) -const facebookUrl = computed(() => `https://www.facebook.com/sharer/sharer.php?u=${encodedUrl.value}`) -const whatsappUrl = computed(() => `https://api.whatsapp.com/send?text=${encodedUrl.value}`) -const linkedinUrl = computed(() => `https://www.linkedin.com/sharing/share-offsite/?url=${encodedUrl.value}`) const copyLink = async () => { try { @@ -160,18 +168,25 @@ const copyLink = async () => { console.error("No se pudo copiar") } } +const BASE_URL = typeof window !== "undefined" + ? `${window.location.protocol}//${window.location.host}` + : ""; -const toggleMobile = async () => { - // Si soporta Web Share API → usar nativo - if (navigator.share) { - try { - await navigator.share({ - title: document.title, - url: props.url - }) - } catch (err) {} - } else { - mobileOpen.value = !mobileOpen.value +const fullUrl = computed(() => { + if (props.url.startsWith("http")) { + const url = new URL(props.url) + return `${BASE_URL}${url.pathname}` } -} + + return `${BASE_URL}${props.url}` +}) + +const encodedUrl = computed(() => + encodeURIComponent(fullUrl.value) +) +const twitterUrl = computed(() => `https://twitter.com/intent/tweet?url=${encodedUrl.value}`) +const facebookUrl = computed(() => `https://www.facebook.com/sharer/sharer.php?u=${encodedUrl.value}`) +const whatsappUrl = computed(() => `https://api.whatsapp.com/send?text=${encodedUrl.value}`) +const linkedinUrl = computed(() => `https://www.linkedin.com/sharing/share-offsite/?url=${encodedUrl.value}`) +const instagramUrl = computed(() => `https://www.instagram.com/centrodelreinodepazyjusticia`) \ No newline at end of file diff --git a/src/layouts/MainLayout.astro b/src/layouts/MainLayout.astro index 685ee95..43431ac 100644 --- a/src/layouts/MainLayout.astro +++ b/src/layouts/MainLayout.astro @@ -28,7 +28,7 @@ const { title } = Astro.props; } }); - + + {Astro.url.pathname.includes('/news/') && ( )} diff --git a/src/pages/news/[id].astro b/src/pages/news/[id].astro index 31723b3..8c79145 100644 --- a/src/pages/news/[id].astro +++ b/src/pages/news/[id].astro @@ -16,9 +16,18 @@ export async function getStaticPaths() { props: { post }, })); } -// 2. For your template, you can get the entry directly from the prop const { post } = Astro.props; const { Content } = await render(post); + +const baseUrl = Astro.site ?? "https://mk8nrc8p-4321.brs.devtunnels.ms"; + +const pageUrl = new URL(`/es/news/${post.id}`, baseUrl).toString(); + +const imageUrl = post.data.thumbnail + ? new URL(post.data.thumbnail.src, baseUrl).toString() + : null; + +const description = `${post.data.title} - ${post.data.city ?? ""} ${post.data.country ?? ""}`; --- @@ -30,6 +39,27 @@ const { Content } = await render(post); + + + {post.data.title} + + + + + + + + + + {post.data.gallery && post.data.gallery.length > 0 && post.data.gallery[0].image && ( + <> + + + + + + )} +