Current section
Files
Jump to
Current section
Files
src/chilp.gleam
import chilp/widget
import chilp/widget/anchors
import gleam/option.{type Option}
/// An anchor to the Bluesky post you want to
/// fetch comments from.
/// | Parameter | Description |
/// | --------- | ----------- |
/// | `did` | Your DID, for `@strawmelonjuice.com`, this looks like `"did:plc:jgtfsmv25thfs4zmydtbccnn"`.<br><br>Not sure how to find your DID? <https://bsky-did.neocities.org> is one of the many places where you can easily find it. |
/// | `post_id` | A post id to bind to, you'll find this in a post url `https://bsky.app/profile/<your-username-or-did>/post/[postid]` |
///
///
/// You can also construct this directly if you import `chilp/widget/anchors`.
pub fn bluesky(did did: String, post_id postid: String) {
anchors.Bluesky(did:, postid:)
}
///
/// An anchor to the Fediverse post you want to
/// fetch comments from.
/// | Parameter | Description |
/// | ---------- | ----------- |
/// | `instance` | The instance name, e.g. `"mastodon.social"`, this is where your post is stored, and where chilp will attempt to fetch it from. |
/// | `post_id` | A post id to bind to, you'll find this in a post url `https://instance.social/@<username>/[postid]`. |
/// | | On Sharkey or Misskey this is a note id, found `https://instance.social/notes/[note-id]` |
///
/// You can also construct this directly if you import `chilp/widget/anchors`.
pub fn mastodon(instance instance: String, post_id postid: String) {
anchors.Mastodon(instance:, postid:)
}
/// Widget component!
/// Before adding this component make sure to call `widget.register()` to register it!
///
/// Little example:
/// ```gleam
/// chilp.widget(
/// // We connect to Bluesky...
/// bluesky: option.Some(chilp.bluesky("did:plc:my-did","myPostId")),
/// // ...But not to Mastodon? Sure! Make it a None!
/// mastodon: option.None
/// )
/// ```
///
/// You can also construct this directly if you import `chilp/widget`.
pub fn widget(
bluesky bsky: Option(anchors.Bluesky),
mastodon masto: Option(anchors.Mastodon),
) {
widget.element(masto, bsky)
}