AD
Boost Your Brand on BlueSky—Exclusive banner space to amplify your reach within the BlueSky community.
BSkyInfo LogoBskyInfo
All ToolsCategoriesCollectionsFeed DirectoryLabeler DirectoryArticlesGuidesGlossaryBluesky SDKsSponsor
Submit
All ToolsCategoriesCollectionsFeed DirectoryLabeler DirectoryGuidesGlossaryArticlesBluesky SDKsSponsorSubmit
  1. SDKs
  2. /Other
  3. /bluesky-post
daviddarnes

bluesky-post

A Other SDK for Bluesky and AT Protocol by daviddarnes

A Web Component to display Bluesky posts and their metadata

GitHub Stats

24stars
2forks
1contributors
0open issues

Dates

Created:October 29, 2024
Last updated:March 10, 2025

README

The following content is from bluesky-post's GitHub repository. All rights reserved by the original author.

bluesky-post

A Web Component to display Bluesky posts and their metadata.

Demo | Custom template demo | Further reading

Examples

General usage example:

<script type="module" src="bluesky-post.js"></script>

<bluesky-post>
  <a href="https://bsky.app/profile/darn.es/post/3l7m6ivb6ha2q">
    Discuss on Bluesky
  </a>
</bluesky-post>

Example using a custom template:

<script type="module" src="bluesky-post.js"></script>

<template id="bluesky-post-template">
  <blockquote data-key="content"></blockquote>
</template>

<bluesky-post>
  <a href="https://bsky.app/profile/darn.es/post/3l7m6ivb6ha2q">
    Discuss on Bluesky
  </a>
</bluesky-post>

Example using a more complex custom template:

<script type="module" src="bluesky-post.js"></script>

<template id="bluesky-post-template">
  <dl>
    <dt>Reposts</dt>
    <dd data-key="repostCount"></dd>
    <dt>Replies</dt>
    <dd data-key="replyCount"></dd>
    <dt>Likes</dt>
    <dd data-key="likeCount"></dd>
  </dl>
  <a data-key="url">
    View original post from <strong data-key="username"></strong> on <strong data-key="hostname"></strong>
  </a>
</template>

<bluesky-post>
  <a href="https://bsky.app/profile/darn.es/post/3l7m6ivb6ha2q">
    Discuss on Bluesky
  </a>
</bluesky-post>

Features

This Web Component allows you to:

  • Turn a regular Bluesky post link into a quoted Bluesky post
  • Surface the post metadata alongside the post, e.g. reply count, repost count, like count
  • Use a custom template for all instances of the component on the page using a data-key="name" data attributes
  • Use a custom template for specific instances using the template attribute
  • Retrieve nested data using the data-key attribute and typical JavaScript key referencing, e.g. data-key="record.text"

Installation

You have a few options (choose one of these):

  1. Install via npm: npm install @daviddarnes/bluesky-post
  2. Download the source manually from GitHub into your project.
  3. Skip this step and use the script directly via a 3rd party CDN (not recommended for production use)

Usage

Make sure you include the <script> in your project (choose one of these):

<!-- Host yourself -->
<script type="module" src="bluesky-post.js"></script>
<!-- 3rd party CDN, not recommended for production use -->
<script
  type="module"
  src="https://www.unpkg.com/@daviddarnes/bluesky-post@1.0.0/bluesky-post.js"
></script>
<!-- 3rd party CDN, not recommended for production use -->
<script
  type="module"
  src="https://esm.sh/@daviddarnes/bluesky-post@1.0.0"
></script>

Using a custom template

The default template for the component looks like this:

<figure>
  <blockquote data-key="record.text"></blockquote>
  <figcaption>
    <cite>
      <a data-key="url">@<span data-key="username"></span></a>
    </cite>
    <dl>
      <dt>Reposts</dt>
      <dd data-key="repostCount"></dd>
      <dt>Replies</dt>
      <dd data-key="replyCount"></dd>
      <dt>Likes</dt>
      <dd data-key="likeCount"></dd>
    </dl>
  </figcaption>
</figure>

However you can customise the template by using a <template> element with an id of bluesky-post-template, which will be used for every instance of the component on the page. Here's an example which just exposes the vanity metrics of the Bluesky post as a <dl>:

<template id="bluesky-post-template">
  <dl>
    <dt>Reposts</dt>
    <dd data-key="repostCount"></dd>
    <dt>Replies</dt>
    <dd data-key="replyCount"></dd>
    <dt>Likes</dt>
    <dd data-key="likeCount"></dd>
  </dl>
</template>

You can also use different templates on the same page by using the template attribute to target <template> elements with a specific id:

<template id="custom-template">
  <a data-key="record.text, url"></a>
</template>

<bluesky-post template="custom-template">
  <a href="https://bsky.app/profile/darn.es/post/3l7m6ivb6ha2q">
    Discuss on Bluesky
  </a>
</bluesky-post>

Data is applied using a data-key data attribute. The value of this attribute should correspond to a data point within a Bluesky public post API response. The official Bluesky documentation has an example of a status response here.

Note that for <a> and <img> elements the value won't be applied to it's content if the string being returned starts with http and instead will be applied to the href and src attributes respectively.

Check out the custom template demo as well as the source code for reference.

Credit

With thanks to the following people:

  • Zach Leatherman for inspiring this Web Component repo template

Topics

componentscustomelementcustomelementswebcomponentwebcomponents

Related SDKs

itaru2622bluesky-selfhost-env

bluesky self-hosting tool for easy deploy in anywhere.

95•Other
christopherkennybskyr

Interact with Bluesky Social from R

21•Other
feenkcomgt4atproto

A dedicated environment for AT Protocol build in Glamorous Toolkit.

24•Other
camerahackscfbsky

CFML BlueSky API Wrapper

2•Other
atproto-cljatproto-clj

ATProto Clojure SDK

12•Other
mary-extbluesky-embed

Custom element for embedding Bluesky posts and profile feeds

54•Other

Resources

GitHub RepositoryProject Website

License

MIT

Author

daviddarnes
daviddarnes

Activity

Last commit: March 10, 2025
Commit frequency: Unknown

Our Sponsors

Your Brand Here!

50K+ engaged viewers every month

Limited spots available!

📧 Contact us via email🦋 Contact us on Bluesky
BSkyInfo LogoBskyInfo

The Most Comprehensive Bluesky Tools Directory

Stay updated with the latest Bluesky tools and ecosystem news 🦋

Bluesky butterfly logo
Quick LinksSubmit a ToolSponsorAboutLegal Information
ToolsFeed DirectoryLabeler DirectorySchedulingAnalyticsAll ToolsCategoriesCollectionsTags
ResourcesArticlesBluesky GuidesBluesky GlossaryBluesky SDKsBluesky ResourcesSkyRaffleMeida Coverage
Our ProductsRaffleBlueAiTeach ToolsLaiewAI affiliate listFirsto

This website may contain affiliate links

© 2025 BskyInfo. All rights reserved.