From 491be28cce5caacbfbc4d05082507504c47ad3b5 Mon Sep 17 00:00:00 2001 From: "Calvin A. Allen" Date: Thu, 8 Jan 2026 16:56:42 -0500 Subject: [PATCH 1/4] fix(giscus): add CORS header for custom theme CSS Also show bluesky engagement sections with 0 counts instead of hiding them --- public/_headers | 2 ++ src/components/BlueskyEngagement.astro | 14 +++----------- 2 files changed, 5 insertions(+), 11 deletions(-) create mode 100644 public/_headers diff --git a/public/_headers b/public/_headers new file mode 100644 index 0000000..41c20b8 --- /dev/null +++ b/public/_headers @@ -0,0 +1,2 @@ +/giscus-theme.css + Access-Control-Allow-Origin: https://giscus.app diff --git a/src/components/BlueskyEngagement.astro b/src/components/BlueskyEngagement.astro index c12e00e..f164ca8 100644 --- a/src/components/BlueskyEngagement.astro +++ b/src/components/BlueskyEngagement.astro @@ -129,17 +129,9 @@ const handle = "codingwithcalvin.net"; if (likesLabel) likesLabel.textContent = likes === 1 ? 'like from' : 'likes from'; if (repostsLabel) repostsLabel.textContent = reposts === 1 ? 'repost from' : 'reposts from'; - // Hide likers section if no likes - const likersSection = container.querySelector('.likers-section'); - if (likes === 0 && likersSection) { - likersSection.classList.add('hidden'); - } - - // Hide reposters section if no reposts - const repostersSection = container.querySelector('.reposters-section'); - if (reposts === 0 && repostersSection) { - repostersSection.classList.add('hidden'); - } + // Note: We always show the sections even with 0 counts + // The count displays "0 likes from" / "0 reposts from" + // Avatars area remains empty when there are no likers/reposters // Update Bluesky link if (blueskyLink) { From e29d09a555c468e7eecd4bb0dd264d068cf9012a Mon Sep 17 00:00:00 2001 From: "Calvin A. Allen" Date: Thu, 8 Jan 2026 16:59:36 -0500 Subject: [PATCH 2/4] feat(bluesky): add sad face placeholder when no engagement --- src/components/BlueskyEngagement.astro | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/components/BlueskyEngagement.astro b/src/components/BlueskyEngagement.astro index f164ca8..a44aeea 100644 --- a/src/components/BlueskyEngagement.astro +++ b/src/components/BlueskyEngagement.astro @@ -129,9 +129,24 @@ const handle = "codingwithcalvin.net"; if (likesLabel) likesLabel.textContent = likes === 1 ? 'like from' : 'likes from'; if (repostsLabel) repostsLabel.textContent = reposts === 1 ? 'repost from' : 'reposts from'; - // Note: We always show the sections even with 0 counts - // The count displays "0 likes from" / "0 reposts from" - // Avatars area remains empty when there are no likers/reposters + // Show sad face when no engagement + const sadFaceHtml = `
+ + + + + + +
`; + + if (likes === 0 && likersAvatars) { + likersAvatars.innerHTML = sadFaceHtml; + } + + const repostersAvatars = container.querySelector('.reposters-avatars'); + if (reposts === 0 && repostersAvatars) { + repostersAvatars.innerHTML = sadFaceHtml; + } // Update Bluesky link if (blueskyLink) { @@ -179,7 +194,6 @@ const handle = "codingwithcalvin.net"; } // Fetch reposters for avatars (limit to 50) - const repostersAvatars = container.querySelector('.reposters-avatars'); if (reposts > 0 && repostersAvatars) { const repostsRes = await fetch( `https://public.api.bsky.app/xrpc/app.bsky.feed.getRepostedBy?uri=${encodeURIComponent(atUri)}&limit=50` From a5439947f3fd795e941946f0b8440a3b4ead0732 Mon Sep 17 00:00:00 2001 From: "Calvin A. Allen" Date: Thu, 8 Jan 2026 17:01:13 -0500 Subject: [PATCH 3/4] feat(rss): add blueskyPostId to RSS feed items --- src/pages/rss.xml.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pages/rss.xml.ts b/src/pages/rss.xml.ts index 78a2f42..8fccbf6 100644 --- a/src/pages/rss.xml.ts +++ b/src/pages/rss.xml.ts @@ -50,8 +50,16 @@ export async function GET(context: APIContext) { }; } + // Add custom data for bluesky post ID if present + if (post.data.blueskyPostId) { + item.customData = `${post.data.blueskyPostId}`; + } + return item; }), + xmlns: { + bluesky: 'https://bsky.app/ns', + }, customData: `en-us`, }); } From fc993521e666635c27f69a9d0b4f9f5105519cea Mon Sep 17 00:00:00 2001 From: "Calvin A. Allen" Date: Thu, 8 Jan 2026 17:06:31 -0500 Subject: [PATCH 4/4] fix(giscus): use worker script for CORS headers Cloudflare Workers doesn't support _headers file. Added a worker script to add CORS header for giscus-theme.css. --- public/_headers | 2 -- src/worker.ts | 21 +++++++++++++++++++++ wrangler.toml | 2 ++ 3 files changed, 23 insertions(+), 2 deletions(-) delete mode 100644 public/_headers create mode 100644 src/worker.ts diff --git a/public/_headers b/public/_headers deleted file mode 100644 index 41c20b8..0000000 --- a/public/_headers +++ /dev/null @@ -1,2 +0,0 @@ -/giscus-theme.css - Access-Control-Allow-Origin: https://giscus.app diff --git a/src/worker.ts b/src/worker.ts new file mode 100644 index 0000000..7d4dcc4 --- /dev/null +++ b/src/worker.ts @@ -0,0 +1,21 @@ +export default { + async fetch(request: Request, env: { ASSETS: Fetcher }): Promise { + const url = new URL(request.url); + + // Serve assets from the dist directory + const response = await env.ASSETS.fetch(request); + + // Add CORS header for giscus theme CSS + if (url.pathname === '/giscus-theme.css') { + const newHeaders = new Headers(response.headers); + newHeaders.set('Access-Control-Allow-Origin', 'https://giscus.app'); + return new Response(response.body, { + status: response.status, + statusText: response.statusText, + headers: newHeaders, + }); + } + + return response; + }, +}; diff --git a/wrangler.toml b/wrangler.toml index 4d2b36d..7917908 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -1,5 +1,7 @@ name = "codingwithcalvin-net" compatibility_date = "2024-12-01" +main = "src/worker.ts" [assets] directory = "./dist" +binding = "ASSETS"