browniebroke.com

Adding "share on Bluesky" to my blog

November 18, 2024
Edit on Github

I just added support for sharing my posts on Bluesky from the bottom of my posts and TIL.

The way it works is quite similar to Tweeter/X and since I already had this feature, it was pretty quick to adapt.

The main difference is that Tweeter has several parameters to provide your text, URL, hashtags and mentions separately, while the Bluesky method has a single field. Here is how it looks like:

function getBskySharingUrl(title, tags, postUrl, bskyUsername) {
  const hashtagsStr = tags
    ? tags.map((ht) => `#${ht.replace(' ', '')}`).join(' ')
    : ''
  const bskyParams = new URLSearchParams({
    text: `${title} by @${bskyUsername} ${postUrl} ${hashtagsStr}`,
  }).toString()
  return `https://bsky.app/intent/compose?${bskyParams}`
}

You can see the whole implementation here.

I pass my own username as bskyUsername and that doesn’t seem to pull through, it’s showing as text instead of being recognised as my handle. Let me know if you know how to fix that.

Liked it? Please share it!

© 2024, Built with Gatsby