Skip to content

Releases: ascorbic/astro-loaders

@ascorbic/youtube-loader@0.0.2

05 Jul 20:48
883c713

Choose a tag to compare

Patch Changes

@ascorbic/feed-loader@2.0.1

26 Jun 08:10
e89af9b

Choose a tag to compare

Patch Changes

@ascorbic/bluesky-loader@0.1.0

22 Jun 09:45
983ae5e

Choose a tag to compare

Minor Changes

  • #91 feb8d4b Thanks @ascorbic! - Adds live Bluesky loader

    Adds liveBlueskyLoader for Astro's experimental Live Content Collections feature. This loader fetches Bluesky posts in real-time, complementing the existing build-time authorFeedLoader.

    The key difference is that while authorFeedLoader fetches data at build time for static generation, liveBlueskyLoader retrieves fresh content on-demand during server-side rendering or client-side navigation.

    Getting Started

    Prerequisites
    • Astro 5.10.0+ with experimental Live Content Collections enabled
    • @ascorbic/bluesky-loader package installed
    Basic Usage

    Create a live collection in your live.config.ts:

    import { defineLiveCollection } from "astro:content";
    import { liveBlueskyLoader } from "@ascorbic/bluesky-loader";
    
    const liveBluesky = defineLiveCollection({
      type: "live",
      loader: liveBlueskyLoader({
        identifier: "your-handle.bsky.social", // Optional: can also be set in filters
        service: "https://public.api.bsky.app", // Optional: defaults to public API
      }),
    });
    
    export const collections = { liveBluesky };
    Using in Pages

    Fetch posts in your Astro pages:

    ---
    import { getLiveCollection, getLiveEntry } from 'astro:content';
    
    // Get filtered posts
    const posts = await getLiveCollection('liveBluesky', (post) =>
      post.data.record.text.includes('astro')
    );
    
    // Get a specific post by AT URI
    const post = await getLiveEntry('liveBluesky', 'at://did:plc:user/app.bsky.feed.post/id');
    ---

    Features

    • Real-time data fetching using AT Protocol's getPosts method
    • Flexible configuration - set identifier globally or per-request
    • Filtering options: limit, date ranges, post types, and more
    • Error handling with specific error codes and helpful messages
    • Full TypeScript support with exported interfaces
    • Configurable service URLs for custom Bluesky instances

@ascorbic/feed-loader@2.0.0

21 Jun 17:21
ecdf149

Choose a tag to compare

Major Changes

  • #85 8c0c2a0 Thanks @ascorbic! - BREAKING CHANGE: Updated underlying feed parser library

    This release updates the underlying feed parsing library from the previous parser to @rowanmanning/feed-parser, which provides more robust and standardized feed parsing. There is a legacy mode for the previous data shape. This change includes several breaking changes to the data structure:

    Schema Changes

    Category Structure

    • BREAKING: Category objects now use label, term, and url fields instead of name and domain
      • Old: { name: string, domain: string | null }
      • New: { label: string, term: string, url: string | null }

    Media/Enclosure Structure

    • BREAKING: Media objects now include additional fields and renamed properties
      • Old: { url: string, type: string | null, length: number | null }
      • New: { url: string, image: string | null, title: string | null, length: number | null, type: string | null, mimeType: string | null }

    Field Name Changes

    • BREAKING: link field renamed to url
    • BREAKING: guid field renamed to id
    • BREAKING: Atom summary field now maps to description (consistent with RSS)
    • BREAKING: RSS/Atom enclosure/link[@rel=enclosure] elements now map to media array

    Error Message Changes

    • Updated error messages to match new parser behavior:
      • "Item does not have a guid, skipping" → "Item does not have an id or url, skipping"
      • "Response body is empty" → "Feed response is empty"

    Benefits

    • More robust XML/Atom/RSS parsing
    • Better handling of malformed feeds
    • Standardized data structure across feed types
    • Improved character encoding support
    • More comprehensive category and media handling

    Legacy Mode Support

    To ease migration, this release includes a temporary legacy mode that maintains backward compatibility:

    // Enable legacy mode for backward compatibility
    const loader = feedLoader({
      url: "https://example.com/feed.xml",
      legacy: true, // Will show deprecation warning
    });

    ⚠️ Legacy mode is deprecated and will be removed in a future major version. Use it only as a temporary migration aid.

    Migration Guide

    Option 1: Use Legacy Mode (Temporary)

    Enable legacy mode to maintain the old data structure while you plan your migration:

    const loader = feedLoader({
      url: "https://example.com/feed.xml",
      legacy: true,
    });
    // Data will be in the old format with categories[].name, enclosures, link, guid

    Option 2: Update to New Format (Recommended)

    Update your code to handle the new structured data format:

    Field Name Changes

    // Item fields
    item.link  item.url
    item.guid  item.id
    item.pubdate/item.date  item.published
    item.summary  item.description (Atom feeds)
    item.enclosures  item.media

    Author Structure Change

    // Old: Single string format
    item.author = "email (name)";
    
    // New: Array of objects
    item.authors = [{ email: "email", name: "name" }];
    // Access: item.authors[0]?.name, item.authors[0]?.email

    Category Structure Change

    // Old: Array of strings
    item.categories = ["category1", "category2"];
    
    // New: Array of objects
    item.categories = [{ label: "category1", term: "category1", url: null }];
    // Access: item.categories[0].label

    Media/Enclosure Structure Change

    // Old: Basic enclosure format
    item.enclosures = [
      {
        url: "http://example.com/file.mp3",
        type: "audio/mpeg",
        length: "1234",
      },
    ];
    
    // New: Enhanced media format
    item.media = [
      {
        url: "http://example.com/file.mp3",
        mimeType: "audio/mpeg",
        length: 1234,
        image: null,
        title: null,
      },
    ];

    Image Structure Change

    // Old: Simple object with undefined for missing values
    item.image = { url: "http://example.com/image.jpg", title: undefined };
    
    // New: Full object structure
    item.image = {
      url: "http://example.com/image.jpg",
      title: "Image Title",
      description: "Image description",
    };

    Meta Structure Changes

    // Feed generator changed from string to object
    meta.generator = "WordPress"  feed.generator = { name: "WordPress" }
    
    // Authors follow same pattern as items
    meta.author = "email (name)"  feed.authors = [{ email: "email", name: "name" }]

    Most users who only access title, description, url, and basic fields will not need changes.

Minor Changes

  • #88 1049d3e Thanks @ascorbic! - Adds experimental live feed loader

    Adds a new liveFeedLoader for Astro's experimental live content collections feature. This allows RSS/Atom feeds to be fetched at request time rather than build time, enabling real-time content updates without rebuilds.

    Features:

    • Runtime feed loading with liveFeedLoader()
    • Support for RSS, Atom, and RDF feeds
    • Collection filtering (limit, category, author, date ranges)
    • Individual entry loading by ID or URL
    • Structured error handling with FeedLoadError and FeedValidationError
    • TypeScript support with proper generics

    Requirements:

    • Astro 5.10.0 or later
    • Experimental live content collections enabled in astro.config.mjs

    Usage:

    // src/live.config.ts
    import { defineLiveCollection } from "astro:content";
    import { liveFeedLoader } from "@ascorbic/feed-loader";
    
    const news = defineLiveCollection({
      type: "live",
      loader: liveFeedLoader({
        url: "https://feeds.example.com/news.xml",
      }),
    });

    The existing feedLoader remains unchanged and fully compatible.

@ascorbic/bluesky-loader@0.0.3

17 Nov 10:49
7d59487

Choose a tag to compare

Patch Changes

@ascorbic/airtable-loader@1.0.5

17 Nov 10:49
7d59487

Choose a tag to compare

Patch Changes

  • #69 3df2c6e Thanks @ascorbic! - Fixes type mapping for various types.

    Rewrites the type mapping to be more robust and handle more types. This should fix issues with some types not being correctly mapped.

@ascorbic/bluesky-loader@0.0.2

07 Nov 11:54
dca1f7c

Choose a tag to compare

Patch Changes

@ascorbic/bluesky-loader@0.0.1

03 Nov 18:06
469b2d2

Choose a tag to compare

Patch Changes

@ascorbic/mock-loader@2.0.2

28 Oct 13:54
fe79e52

Choose a tag to compare

Patch Changes

@ascorbic/feed-loader@1.0.4

28 Oct 13:54
fe79e52

Choose a tag to compare

Patch Changes