Insightcn

RSS Feeds

Generate RSS feeds from your registry.

Insightcn can generate RSS 2.0 compliant feeds from your registry. This allows users to subscribe to updates and stay informed about new components.

How It Works

  1. You call generateRegistryRssFeed with your registry configuration
  2. SDK fetches your registry data
  3. SDK generates XML feed with component information
  4. Feed includes pub dates from GitHub commits (if configured)

Basic Usage

import { generateRegistryRssFeed } from "@insightcn/sdk";

const rss = await generateRegistryRssFeed({
  baseUrl: "https://your-registry.com",
  rss: {
    title: "My Shadcn Registry",
    description: "Custom components for shadcn/ui",
  },
});

console.log(rss); // XML string

Configuration Options

OptionTypeDescription
baseUrlstringYour registry base URL
rss.titlestringFeed title
rss.descriptionstringFeed description
rss.endpointstringRSS endpoint path (default: /rss)
rss.limitnumberMaximum number of items in feed
github.ownerstringGitHub repository owner
github.repostringGitHub repository name
github.tokenstringGitHub API token for commit dates

GitHub Integration

For accurate pub dates, configure GitHub integration:

const rss = await generateRegistryRssFeed({
  baseUrl: "https://your-registry.com",
  rss: {
    title: "My Shadcn Registry",
    description: "Custom components for shadcn/ui",
  },
  github: {
    owner: "your-org",
    repo: "your-registry",
    token: process.env.GITHUB_TOKEN,
  },
});

Next.js Example

Here's a complete Next.js API route for serving RSS feeds:

app/api/rss/route.ts
import { NextResponse } from "next/server";
import { generateRegistryRssFeed } from "@insightcn/sdk";

export async function GET() {
  const rssFeed = await generateRegistryRssFeed({
    baseUrl: "https://your-registry.com",
    rss: {
      title: "My Shadcn Registry",
      description: "Custom components for shadcn/ui",
      endpoint: "/api/rss",
    },
    github: {
      owner: "your-org",
      repo: "your-registry",
      token: process.env.GITHUB_TOKEN,
    },
  });

  if (!rssFeed) {
    return new NextResponse("No items found", { status: 404 });
  }

  return new NextResponse(rssFeed, {
    headers: {
      "Content-Type": "application/rss+xml",
      "Cache-Control": "public, max-age=3600",
    },
  });
}

On this page