https://github.com/daviddarnes/bluesky-post
A Web Component to display Bluesky posts and their metadata
https://github.com/daviddarnes/bluesky-post
components customelement customelements webcomponent webcomponents
Last synced: 4 months ago
JSON representation
A Web Component to display Bluesky posts and their metadata
- Host: GitHub
- URL: https://github.com/daviddarnes/bluesky-post
- Owner: daviddarnes
- License: mit
- Created: 2024-10-29T11:28:06.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-07T08:28:51.000Z (about 1 year ago)
- Last Synced: 2025-07-21T05:13:39.570Z (7 months ago)
- Topics: components, customelement, customelements, webcomponent, webcomponents
- Language: HTML
- Homepage: https://daviddarnes.github.io/bluesky-post/demo.html
- Size: 13.7 KB
- Stars: 25
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# `bluesky-post`
A Web Component to display Bluesky posts and their metadata.
**[Demo](https://daviddarnes.github.io/bluesky-post/demo.html)** | **[Custom template demo](https://daviddarnes.github.io/bluesky-post/demo-custom-template.html)** | **[Further reading](https://darn.es/bluesky-post-web-component/)**
## Examples
General usage example:
```html
```
Example using a custom template:
```html
```
Example using a more complex custom template:
```html
- Reposts
- Replies
- Likes
View original post from on
```
## 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](https://www.npmjs.com/package/@daviddarnes/bluesky-post): `npm install @daviddarnes/bluesky-post`
1. [Download the source manually from GitHub](https://github.com/daviddarnes/bluesky-post/releases) into your project.
1. Skip this step and use the script directly via a 3rd party CDN (not recommended for production use)
### Usage
Make sure you include the `` in your project (choose one of these):
```html
<!-- Host yourself -->
<script type="module" src="bluesky-post.js">
```
```html
```
```html
```
### Using a custom template
The default template for the component looks like this:
```html
@
- Reposts
- Replies
- Likes
```
However you can customise the template by using a `` 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 `
- `:
- Reposts
- Replies
- Likes
```html
```
You can also use different templates on the same page by using the `template` attribute to target `` elements with a specific `id`:
```html
```
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](https://docs.bsky.app/docs/api/app-bsky-feed-get-posts). The official Bluesky documentation has [an example of a status response here](https://docs.bsky.app/docs/api/app-bsky-feed-get-posts#responses).
Check out the [custom template demo](https://daviddarnes.github.io/bluesky-post/demo-custom-template.html) as well as [the source code](https://github.com/daviddarnes/bluesky-post/blob/main/demo-custom-template.html) for reference.
## Credit
With thanks to the following people:
- [Zach Leatherman](https://zachleat.com) for inspiring this [Web Component repo template](https://github.com/daviddarnes/component-template)