npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vite-plugin-rss

v0.0.6

Published

Create an RSS feed from an SPA at bundle time.

Downloads

25

Readme

RSS Plugin

Create an RSS feed from an SPA at bundle time.

Installation

yarn add -D vite-plugin-rss
npm install -D vite-plugin-rss

Usage

Plugin Options:

interface Options {
  channel: Channel; // RSS channel xml config
  fileName?: string; // RSS xml file output name, defaults to 'feed.xml'
  mode: "meta" | "define"; // the mode to use for item generation
  itmes?: Item[]; // statically defined items in 'define' mode
}

This plugin can run in two modes: 'meta' or 'define'.

'define' mode

In 'define' mode, you define your RSS items in the configuration of the plugin.

// vite.config.ts
import { defineConfig } from "vite";
import { rssPlugin } from "vite-plugin-rss";

export default defineConfig({
  plugins: [
    rssPlugin({
      mode: "define",
      items: [
        {
          title: "Second Post",
          link: "http://lvh.me:3000/test/2",
          pubDate: new Date("1/1/2000"),
        },
        {
          title: "First Post",
          link: "http://lvh.me:3000/test/1",
          pubDate: new Date("1/1/1990"),
        },
      ],
      channel: {
        title: "Test RSS Feed",
        link: "http://lvh.me:3000",
        description: "Test rss feed for vite-plugin-rss.",
      },
    }),
  ],
  build: {
    outDir: "dist_test",
  },
});

'meta' mode

'meta' mode will look for rss items by examining module info from another plugin's transform or load step.

// vite.config.ts
import { defineConfig } from "vite";
import { rssPlugin } from "vite-plugin-rss";

export default defineConfig({
  plugins: [
    myPlugin(),
    rssPlugin({
      mode: "meta",
      channel: {
        title: "Test RSS Feed",
        link: "http://lvh.me:3000",
        description: "Test rss feed for vite-plugin-rss.",
      },
    }),
  ],
  build: {
    outDir: "dist_test",
  },
});

function myPlugin() {
  return {
    name: "my-plugin",
    load(id) {
      if (id.includes("post-1")) {
        return {
          meta: {
            rssItem: {
              title: "First Post",
              link: "http://lvh.me:3000/test/1",
              pubDate: new Date("1/1/1990"),
            },
          },
        };
      }

      if (id.includes("post-2")) {
        return {
          meta: {
            rssItem: {
              title: "Second Post",
              link: "http://lvh.me:3000/test/2",
              pubDate: new Date("1/1/2000"),
            },
          },
        };
      }
    },
  };
}

The output will look something like this:

<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Test RSS Feed</title>
    <link>http://lvh.me:3000</link>
    <description>Test rss feed for vite-plugin-rss.</description>
    <atom:link href="http://lvh.me:3000/feed.xml" rel="self" type="application/rss+xml"/>
    <item>
      <title>Second Post</title>
      <link>http://lvh.me:3000/test/2</link>
      <pubDate>Sat, 01 Jan 2000 07:00:00 GMT</pubDate>
    </item>
    <item>
      <title>First Post</title>
      <link>http://lvh.me:3000/test/1</link>
      <pubDate>Mon, 01 Jan 1990 07:00:00 GMT</pubDate>
    </item>
  </channel>
</rss>