Skip to content

Commit a58bbf8

Browse files
committed
Build fixes
1 parent 9f0d537 commit a58bbf8

File tree

2 files changed

+70
-10
lines changed

2 files changed

+70
-10
lines changed

src/components/ShareButtons.astro

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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>

src/pages/og-image/[...slug].png.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import type { ReactNode } from 'react';
1111

1212
import RobotoMono from '@assets/roboto-mono-regular.ttf';
1313
import RobotoMonoBold from '@assets/roboto-mono-700.ttf';
14+
import fs from 'node:fs';
15+
import path from 'node:path';
1416

1517
const ogOptions: SatoriOptions = {
1618
width: 1200,
@@ -32,6 +34,11 @@ const ogOptions: SatoriOptions = {
3234
],
3335
};
3436

37+
// Load the nick avatar image as base64
38+
const avatarImagePath = path.join(process.cwd(), 'src', 'assets', 'nick.png');
39+
const avatarImageData = fs.readFileSync(avatarImagePath);
40+
const avatarBase64 = `data:image/png;base64,${avatarImageData.toString('base64')}`;
41+
3542
const markup = (title: string, pubDate: string) => html`
3643
<div tw="flex flex-col w-full h-full bg-[#1d1f21] text-[#c9cacc]">
3744
<div tw="flex flex-col flex-1 w-full p-10 justify-center">
@@ -40,7 +47,7 @@ const markup = (title: string, pubDate: string) => html`
4047
</div>
4148
<div tw="flex items-center justify-between w-full p-10 border-t border-[#2bbc89] text-xl">
4249
<div tw="flex items-center">
43-
<img src="https://www.nickhodges.com/assets/favicons/apple-icon.png" alt="Nick Image" height="60" />
50+
<img src="${avatarBase64}" width="60" height="60" alt="Nick Image" tw="rounded-full" />
4451
<p tw="ml-3 font-semibold">${siteConfig.title}</p>
4552
</div>
4653
<p>by ${siteConfig.author}</p>

0 commit comments

Comments
 (0)