@@ -28,46 +28,99 @@ const emailUrl = `mailto:?subject=${encodedTitle}&body=${encodedDescription}%0A%
2828<div class =" not-prose share-buttons mt-10 border-t border-gray-200 pt-8 dark:border-gray-700" >
2929 <h3 class =" mb-4 text-lg font-medium text-accent-2" >Share this post</h3 >
3030 <div class =" flex flex-wrap gap-3" >
31+ <button
32+ id =" web-share-btn"
33+ class =" inline-flex items-center rounded-md bg-accent-2 px-4 py-2 text-sm text-white transition hover:bg-opacity-90 focus:outline-none focus:ring-2 focus:ring-accent-1 focus:ring-offset-2 dark:focus:ring-offset-gray-900"
34+ aria-label =" Share this post"
35+ data-title ={ title }
36+ data-description ={ description }
37+ data-url ={ fullUrl }
38+ >
39+ <Icon name =" mdi:share" class =" mr-2 h-5 w-5" aria-hidden =" true" />
40+ <span >Share</span >
41+ </button >
42+
3143 <a
3244 href ={ twitterUrl }
3345 target =" _blank"
3446 rel =" noopener noreferrer"
35- class =" inline-flex items-center rounded-md bg-[#000000] px-4 py-2 text-sm text-white transition hover:bg-opacity-90"
47+ class =" inline-flex items-center rounded-md bg-[#000000] px-4 py-2 text-sm text-white transition hover:bg-opacity-90 focus:outline-none focus:ring-2 focus:ring-accent-1 focus:ring-offset-2 dark:focus:ring-offset-gray-900 "
3648 aria-label =" Share on Twitter"
3749 >
38- <Icon name =" mdi:twitter" class =" mr-2 h-5 w-5" />
50+ <Icon name =" mdi:twitter" class =" mr-2 h-5 w-5" aria-hidden = " true " />
3951 <span >X / Twitter</span >
4052 </a >
4153
4254 <a
4355 href ={ facebookUrl }
4456 target =" _blank"
4557 rel =" noopener noreferrer"
46- class =" inline-flex items-center rounded-md bg-[#1877F2] px-4 py-2 text-sm text-white transition hover:bg-opacity-90"
58+ class =" inline-flex items-center rounded-md bg-[#1877F2] px-4 py-2 text-sm text-white transition hover:bg-opacity-90 focus:outline-none focus:ring-2 focus:ring-accent-1 focus:ring-offset-2 dark:focus:ring-offset-gray-900 "
4759 aria-label =" Share on Facebook"
4860 >
49- <Icon name =" mdi:facebook" class =" mr-2 h-5 w-5" />
61+ <Icon name =" mdi:facebook" class =" mr-2 h-5 w-5" aria-hidden = " true " />
5062 <span >Facebook</span >
5163 </a >
5264
5365 <a
5466 href ={ linkedinUrl }
5567 target =" _blank"
5668 rel =" noopener noreferrer"
57- class =" inline-flex items-center rounded-md bg-[#0A66C2] px-4 py-2 text-sm text-white transition hover:bg-opacity-90"
69+ class =" inline-flex items-center rounded-md bg-[#0A66C2] px-4 py-2 text-sm text-white transition hover:bg-opacity-90 focus:outline-none focus:ring-2 focus:ring-accent-1 focus:ring-offset-2 dark:focus:ring-offset-gray-900 "
5870 aria-label =" Share on LinkedIn"
5971 >
60- <Icon name =" mdi:linkedin" class =" mr-2 h-5 w-5" />
72+ <Icon name =" mdi:linkedin" class =" mr-2 h-5 w-5" aria-hidden = " true " />
6173 <span >LinkedIn</span >
6274 </a >
6375
6476 <a
6577 href ={ emailUrl }
66- class =" inline-flex items-center rounded-md bg-[#4CAF50] px-4 py-2 text-sm text-white transition hover:bg-opacity-90"
78+ class =" inline-flex items-center rounded-md bg-[#4CAF50] px-4 py-2 text-sm text-white transition hover:bg-opacity-90 focus:outline-none focus:ring-2 focus:ring-accent-1 focus:ring-offset-2 dark:focus:ring-offset-gray-900 "
6779 aria-label =" Share via email"
6880 >
69- <Icon name =" mdi:email" class =" mr-2 h-5 w-5" />
81+ <Icon name =" mdi:email" class =" mr-2 h-5 w-5" aria-hidden = " true " />
7082 <span >Email</span >
7183 </a >
7284 </div >
73- </div >
85+ </div >
86+
87+ <script >
88+ // Web Share API support
89+ const shareButton = document.getElementById('web-share-btn');
90+
91+ if (navigator.share) {
92+ shareButton.addEventListener('click', async () => {
93+ try {
94+ const title = shareButton.dataset.title;
95+ const description = shareButton.dataset.description;
96+ const url = shareButton.dataset.url;
97+
98+ await navigator.share({
99+ title,
100+ text: description,
101+ url
102+ });
103+ } catch (err) {
104+ console.error('Share failed:', err);
105+ }
106+ });
107+ } else {
108+ shareButton.style.display = 'none';
109+ }
110+
111+ // Enhanced link behavior for social sharing
112+ document.querySelectorAll('.share-buttons a').forEach(link => {
113+ link.addEventListener('click', (e) => {
114+ try {
115+ // If it's not the email link, prevent default and open in popup
116+ if (!link.href.startsWith('mailto:')) {
117+ e.preventDefault();
118+ window.open(link.href, 'share-popup', 'width=600,height=480');
119+ }
120+ } catch (err) {
121+ console.error('Share error:', err);
122+ // Don't prevent default - let the link work normally as fallback
123+ }
124+ });
125+ });
126+ </script >
0 commit comments