{"_id":"@daviddarnes/bluesky-post","name":"@daviddarnes/bluesky-post","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@daviddarnes/bluesky-post","version":"1.0.0","description":"A Web Component to display Bluesky posts and their metadata","main":"bluesky-post.js","scripts":{"start":"npx http-server ."},"repository":{"type":"git","url":"git+https://github.com/daviddarnes/bluesky-post.git"},"keywords":["web","component","components","web components","custom elements"],"license":"MIT","publishConfig":{"access":"public"},"bugs":{"url":"https://github.com/daviddarnes/bluesky-post/issues"},"author":{"name":"David Darnes","email":"me@daviddarnes.com","url":"https://darn.es/"},"homepage":"https://github.com/daviddarnes/bluesky-post#readme","gitHead":"3e277f1b59bbb9e4881cd9d50c881797e5aff07f","_id":"@daviddarnes/bluesky-post@1.0.0","_nodeVersion":"16.20.2","_npmVersion":"8.19.4","dist":{"integrity":"sha512-wcyP202NeHtv0PqDAicjhwhdHHAriY41UX1RBOUOyFjFSGorghHXvYAP4qz2pjsAHiY78Ar2c/yF562+nyDX9Q==","shasum":"ae5566949e6e28f6e91f8350b05486353db579f4","tarball":"https://registry.npmjs.org/@daviddarnes/bluesky-post/-/bluesky-post-1.0.0.tgz","fileCount":10,"unpackedSize":15494,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCEWO6Vs67eSIlLMK9mzsNb0IfiVaW1avNW2PV6pZl0MgIgPogJBMSypjPNUO3IWJTK39YgS75shzydMx3U9DqpB3Y="}]},"_npmUser":{"name":"daviddarnes","email":"me@daviddarnes.com"},"directories":{},"maintainers":[{"name":"daviddarnes","email":"me@daviddarnes.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/bluesky-post_1.0.0_1730213230796_0.007722736478101844"},"_hasShrinkwrap":false}},"time":{"created":"2024-10-29T14:47:10.679Z","1.0.0":"2024-10-29T14:47:10.955Z","modified":"2024-10-29T14:47:11.226Z"},"maintainers":[{"name":"daviddarnes","email":"me@daviddarnes.com"}],"description":"A Web Component to display Bluesky posts and their metadata","homepage":"https://github.com/daviddarnes/bluesky-post#readme","keywords":["web","component","components","web components","custom elements"],"repository":{"type":"git","url":"git+https://github.com/daviddarnes/bluesky-post.git"},"author":{"name":"David Darnes","email":"me@daviddarnes.com","url":"https://darn.es/"},"bugs":{"url":"https://github.com/daviddarnes/bluesky-post/issues"},"license":"MIT","readme":"# `bluesky-post`\n\nA Web Component to display Bluesky posts and their metadata.\n\n**[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/)**\n\n## Examples\n\nGeneral usage example:\n\n```html\n<script type=\"module\" src=\"bluesky-post.js\"></script>\n\n<bluesky-post>\n  <a href=\"https://bsky.app/profile/darn.es/post/3l7m6ivb6ha2q\">\n    Discuss on Bluesky\n  </a>\n</bluesky-post>\n```\n\nExample using a custom template:\n\n```html\n<script type=\"module\" src=\"bluesky-post.js\"></script>\n\n<template id=\"bluesky-post-template\">\n  <blockquote data-key=\"content\"></blockquote>\n</template>\n\n<bluesky-post>\n  <a href=\"https://bsky.app/profile/darn.es/post/3l7m6ivb6ha2q\">\n    Discuss on Bluesky\n  </a>\n</bluesky-post>\n```\n\nExample using a more complex custom template:\n\n```html\n<script type=\"module\" src=\"bluesky-post.js\"></script>\n\n<template id=\"bluesky-post-template\">\n  <dl>\n    <dt>Reposts</dt>\n    <dd data-key=\"reblogs_count\"></dd>\n    <dt>Replies</dt>\n    <dd data-key=\"replies_count\"></dd>\n    <dt>Favourites</dt>\n    <dd data-key=\"favourites_count\"></dd>\n  </dl>\n  <a data-key=\"url\">\n    View original post from <img alt=\"avatar\" data-key=\"account.avatar\" />\n    <strong data-key=\"account.display_name\"></strong> on\n    <strong data-key=\"hostname\"></strong>\n  </a>\n</template>\n\n<bluesky-post>\n  <a href=\"https://bsky.app/profile/darn.es/post/3l7m6ivb6ha2q\">\n    Discuss on Bluesky\n  </a>\n</bluesky-post>\n```\n\n## Features\n\nThis Web Component allows you to:\n\n- Turn a regular Bluesky post link into a quoted Bluesky post\n- Surface the post metadata alongside the post, e.g. reply count, repost count, like count\n- Use a custom template for all instances of the component on the page using a `data-key=\"name\"` data attributes\n- Use a custom template for specific instances using the `template` attribute\n- Retrieve nested data using the `data-key` attribute and typical JavaScript key referencing, e.g. `data-key=\"reocrd.text\"`\n\n## Installation\n\nYou have a few options (choose one of these):\n\n1. Install via [npm](https://www.npmjs.com/package/@daviddarnes/bluesky-post): `npm install @daviddarnes/bluesky-post`\n1. [Download the source manually from GitHub](https://github.com/daviddarnes/bluesky-post/releases) into your project.\n1. Skip this step and use the script directly via a 3rd party CDN (not recommended for production use)\n\n### Usage\n\nMake sure you include the `<script>` in your project (choose one of these):\n\n```html\n<!-- Host yourself -->\n<script type=\"module\" src=\"bluesky-post.js\"></script>\n```\n\n```html\n<!-- 3rd party CDN, not recommended for production use -->\n<script\n  type=\"module\"\n  src=\"https://www.unpkg.com/@daviddarnes/bluesky-post@1.0.0/bluesky-post.js\"\n></script>\n```\n\n```html\n<!-- 3rd party CDN, not recommended for production use -->\n<script\n  type=\"module\"\n  src=\"https://esm.sh/@daviddarnes/bluesky-post@1.0.0\"\n></script>\n```\n\n### Using a custom template\n\nThe default template for the component looks like this:\n\n```html\n<figure>\n  <blockquote data-key=\"record.text\"></blockquote>\n  <figcaption>\n    <cite>\n      <a data-key=\"url\">@<span data-key=\"username\"></span></a>\n    </cite>\n    <dl>\n      <dt>Reposts</dt>\n      <dd data-key=\"repostCount\"></dd>\n      <dt>Replies</dt>\n      <dd data-key=\"replyCount\"></dd>\n      <dt>Likes</dt>\n      <dd data-key=\"likeCount\"></dd>\n    </dl>\n  </figcaption>\n</figure>\n```\n\nHowever 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>`:\n\n```html\n<template id=\"bluesky-post-template\">\n  <dl>\n    <dt>Reposts</dt>\n    <dd data-key=\"repostCount\"></dd>\n    <dt>Replies</dt>\n    <dd data-key=\"replyCount\"></dd>\n    <dt>Likes</dt>\n    <dd data-key=\"likeCount\"></dd>\n  </dl>\n</template>\n```\n\nYou can also use different templates on the same page by using the `template` attribute to target `<template>` elements with a specific `id`:\n\n```html\n<template id=\"custom-template\">\n  <a data-key=\"record.text, url\"></a>\n</template>\n\n<bluesky-post template=\"custom-template\">\n  <a href=\"https://bsky.app/profile/darn.es/post/3l7m6ivb6ha2q\">\n    Discuss on Bluesky\n  </a>\n</bluesky-post>\n```\n\nData 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).\n\n_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._\n\nCheck 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.\n\n## Credit\n\nWith thanks to the following people:\n\n- [Zach Leatherman](https://zachleat.com) for inspiring this [Web Component repo template](https://github.com/daviddarnes/component-template)\n","readmeFilename":"README.md"}