
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
@ascorbic/bluesky-loader
Advanced tools
This package provides Bluesky post loaders for Astro. It allows you to load and parse Bluesky posts, and use the data in your Astro site.
This package provides Bluesky post loaders for Astro. It allows you to load and parse Bluesky posts, and use the data in your Astro site.
It provides two types of loaders:
authorFeedLoader
: Build-time loader that caches posts between buildsliveBlueskyLoader
: Live loader that fetches fresh data on each requestnpm install @ascorbic/bluesky-loader
authorFeedLoader
You can then use the build-time loader in your content configuration like this:
// src/content/config.ts
import { defineCollection } from "astro:content";
import { authorFeedLoader } from "@ascorbic/bluesky-loader";
const posts = defineCollection({
loader: authorFeedLoader({
identifier: "mk.gg",
}),
});
export const collections = { posts };
You can then use these like any other content collection in Astro:
---
import { getCollection, type CollectionEntry, render } from "astro:content";
import Layout from "../../layouts/Layout.astro";
const posts = await getCollection("posts");
---
<Layout>
{
posts.map(async (post) => {
const { Content } = await render(post);
return (
<section>
<Content />
<p>{post.data.likeCount} likes</p>
</section>
);
})
}
</Layout>
liveBlueskyLoader
(Experimental)For real-time data that updates on each request, you can use the live loader. This requires Astro 5.10.0 or later with experimental live content collections enabled:
// astro.config.mjs
export default defineConfig({
experimental: {
liveContentCollections: true,
},
});
Create a live collection configuration:
// src/live.config.ts
import { defineLiveCollection } from "astro:content";
import { liveBlueskyLoader } from "@ascorbic/bluesky-loader";
const livePosts = defineLiveCollection({
type: "live",
loader: liveBlueskyLoader({
identifier: "mk.gg", // Optional: can be set in filter instead
service: "https://public.api.bsky.app", // Optional: defaults to public API
}),
});
export const collections = { livePosts };
Use live collections with getLiveCollection()
and getLiveEntry()
:
---
import { getLiveCollection, getLiveEntry } from "astro:content";
// Get posts with filters
const { entries: posts, error } = await getLiveCollection("livePosts", {
limit: 10,
type: "posts_no_replies",
identifier: "different.user", // Override default identifier
since: new Date("2024-01-01"),
});
// Get individual post
const { entry: post } = await getLiveEntry("livePosts", {
id: "at://did:plc:user/app.bsky.feed.post/abc123"
});
export const prerender = false; // Required for live content
---
{error ? (
<p>Error: {error.message}</p>
) : (
<div>
{posts?.map(post => (
<article>
<h3>{post.data.author.displayName}</h3>
<div set:html={post.rendered?.html} />
<p>{post.data.likeCount} likes</p>
</article>
))}
</div>
)}
The authorFeedLoader
function takes an options object with the following properties:
identifier
: The identifier of the author whose feed you want to load. This can be the username (such as mk.gg
) or the full did
limit
: The maximum number of posts to load. Defaults to loading all posts.filter
: Filter the type of posts. Options: posts_and_author_threads
, posts_no_replies
, posts_with_replies
, posts_and_replies
The liveBlueskyLoader
function takes an options object with the following properties:
identifier
(optional): The default identifier of the author whose feed you want to load. Can be overridden in collection filters.service
(optional): The Bluesky service URL. Defaults to "https://public.api.bsky.app"
.When calling getLiveCollection()
, you can pass filter options:
limit
: Maximum number of posts to fetchtype
: Filter the type of posts (posts_and_author_threads
, posts_no_replies
, posts_with_replies
, posts_and_replies
)identifier
: Override the default identifier from loader optionssince
: Only fetch posts after this dateuntil
: Only fetch posts before this dateWhen calling getLiveEntry()
, you can pass filter options:
id
: The AT URI of the post (e.g., "at://did:plc:user/app.bsky.feed.post/abc123"
)uri
: Alternative to id
- the AT URI of the postThe post data
property is a PostView
object, and is fully typed. To make it easier to display posts, we generate HTML for each entry. The render()
function is optional, but creates a component from the post content. This handles links, mentions and tags in the post content. You can access images and other embeds in the data.embed
object. If you want access to the rendered HTML, you can use rendered.html
field.
However you might want to use the helpers in the @atproto/api
package to work with the data. For example, this shows how you can use the embed isView
type guards to check the type of an embed:
---
import { AppBskyEmbedImages, AppBskyEmbedRecordWithMedia } from "@atproto/api";
import { getCollection } from "astro:content";
import Layout from "../../layouts/Layout.astro";
const posts = await getCollection("posts");
---
<Layout>
{
posts.map(async (post) => {
const { embed } = post.data;
return (
<div>
{AppBskyEmbedImages.isView(embed)
? embed.images.map(
(image) => image && <img src={image.thumb} alt={image.alt} />
)
: undefined}
{AppBskyEmbedRecordWithMedia.isView(embed) ? (
<img
src={embed.media.external.uri}
alt={embed.media.external.description}
/>
) : undefined}
</div>
);
})
}
</Layout>
Live collections return errors that you should handle in your components:
---
import { getLiveCollection, LiveEntryNotFoundError } from "astro:content";
const { entries: posts, error } = await getLiveCollection("livePosts");
if (error) {
if (LiveEntryNotFoundError.is(error)) {
console.error(`Posts not found: ${error.message}`);
} else {
console.error(`Error loading posts: ${error.message}`);
}
}
---
The live loader returns specific error codes:
MISSING_IDENTIFIER
: No identifier provided in options or filterINVALID_FILTER
: Missing required filter parametersINVALID_ID_FORMAT
: ID is not a valid AT URI formatENTRY_NOT_FOUND
: Post not found (may have been deleted)COLLECTION_LOAD_ERROR
: Failed to load collection (network/API error)ENTRY_LOAD_ERROR
: Failed to load individual entry (network/API error)Feature | Build-time (authorFeedLoader ) | Live (liveBlueskyLoader ) |
---|---|---|
Performance | Fast (pre-built) | Slower (fetches on request) |
Data freshness | Build-time snapshot | Real-time data |
Caching | Built-in incremental updates | No automatic caching |
Filtering | Limited options | Rich filtering (date, type, user) |
Error handling | Build-time errors | Runtime error handling |
Use case | Static sites, archived content | Dynamic sites, live feeds |
Choose build-time when you want fast loading and don't need real-time updates. Choose live when you need fresh data and can handle the performance trade-off.
FAQs
This package provides Bluesky post loaders for Astro. It allows you to load and parse Bluesky posts, and use the data in your Astro site.
We found that @ascorbic/bluesky-loader demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.