-
+
diff --git a/src/components/core/BasicScripts.astro b/src/components/core/BasicScripts.astro
index efa8072..d325267 100644
--- a/src/components/core/BasicScripts.astro
+++ b/src/components/core/BasicScripts.astro
@@ -37,6 +37,39 @@
document.documentElement.classList.toggle('dark');
localStorage.theme = document.documentElement.classList.contains('dark') ? 'dark' : 'light';
});
+
+ attachEvent('[data-aw-social-share]', 'click', function (elem) {
+ const network = elem.getAttribute('data-aw-social-share');
+ const url = encodeURIComponent(elem.getAttribute('data-aw-url'));
+ const text = encodeURIComponent(elem.getAttribute('data-aw-text'));
+
+ let href;
+ switch (network) {
+ case 'facebook':
+ href = `https://www.facebook.com/sharer.php?u=${url}`;
+ break;
+ case 'twitter':
+ href = `https://twitter.com/intent/tweet?url=${url}&text=${text}`;
+ break;
+ case 'linkedin':
+ href = `https://www.linkedin.com/shareArticle?mini=true&url=${url}&title=${text}`;
+ break;
+ case 'whatsapp':
+ href = `https://wa.me/?text=${text}%20${url}`;
+ break;
+ case "mail":
+ href = `mailto:?subject=%22${text}%22&body=${text}%20${url}`;
+ break;
+
+ default:
+ return;
+ }
+
+ const newlink = document.createElement('a');
+ newlink.target = '_blank';
+ newlink.href = href;
+ newlink.click();
+ });
};
window.onpageshow = function () {
const elem = document.querySelector('[data-aw-toggle-menu]');
diff --git a/src/pages/[...blog]/[slug].astro b/src/pages/[...blog]/[slug].astro
index f54800a..f103423 100644
--- a/src/pages/[...blog]/[slug].astro
+++ b/src/pages/[...blog]/[slug].astro
@@ -23,11 +23,12 @@ export async function getStaticPaths() {
}
const { post } = Astro.props;
+const canonical = post.canonical || getCanonical(getPermalink(post.slug, 'post'))
const meta = {
title: `${post.title} — ${SITE.name}`,
description: post.description,
- canonical: post.canonical || getCanonical(getPermalink(post.slug, 'post')),
+ canonical: canonical,
image: await findImage(post.image),
ogTitle: post.title,
ogType: 'article',
@@ -35,5 +36,5 @@ const meta = {
---
-
+