bluesky-profile-card-embed
v1.0.1
Published
Custom element for embedding Bluesky profile cards
Readme
<bluesky-profile-card-embed>
A custom element for embedding Bluesky profile cards.
Installation
via npm
npm install bluesky-profile-card-embedthen, import the package on your app.
import 'bluesky-profile-card-embed';
import 'bluesky-profile-card-embed/style.css';
import 'bluesky-profile-card-embed/themes/light.css';Usage
<bluesky-profile-card actor="did:plc:2gkh62xvzokhlf6li4ol3b3d">
<a
target="_blank"
href="https://bsky.app/profile/did:plc:2gkh62xvzokhlf6li4ol3b3d"
class="bluesky-profile-card-fallback"
>
@patak.dev's Bluesky profile
</a>
</bluesky-profile-card>Attributes
actorRequired
DID or handle of the accountallow-unauthenticatedOptional
Whether to allow unauthenticated viewingservice-uriOptional
URL to an AppView service, defaults tohttps://public.api.bsky.app
Events
loaded
Fired when the embed has successfully loaded the profile carderror
Fired when the embed fails to load the profile card
SSR usage
The embeds are powered by a static HTML renderer, this renderer can be used directly in your server-rendering framework of choice for a zero-JS experience.
import { fetchProfileCard, renderProfileCard } from 'bluesky-profile-card-embed/core';
import 'bluesky-profile-card-embed/style.css';
import 'bluesky-profile-card-embed/themes/light.css';
// fetch the profile
const controller = new AbortController();
const data = await fetchProfileCard({
actor: `did:plc:ragtjsm2j2vknwkz3zp4oxrd`,
signal: controller.signal,
});
// render the profile
const html = renderProfileCard(data);
return (
<bluesky-profile-card
actor={data.profile?.did}
dangerouslySetInnerHTML={{ __html: html }}
></bluesky-profile-card>
);