Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@cogita/plugin-rss

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cogita/plugin-rss

RSS, Atom, and JSON Feed generation plugin for Cogita blogs, providing comprehensive subscription support with automatic HTML discovery links.

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

@cogita/plugin-rss

npm version TypeScript

中文 | English

RSS, Atom, and JSON Feed generation plugin for Cogita blogs with automatic HTML discovery links.

What is it?

This plugin automatically generates RSS 2.0, Atom, and JSON Feed files from your blog posts and adds discovery links to HTML pages. It's perfect for readers who want to subscribe to your blog updates.

Features

Multiple Feed Formats

  • RSS 2.0 (most widely supported)
  • Atom Feed (modern standard)
  • JSON Feed (developer-friendly)

SEO Optimized

  • Automatic HTML <link> tag injection
  • Proper MIME types and headers
  • Search engine friendly URLs

Highly Configurable

  • Custom feed paths and limits
  • Field mapping from frontmatter
  • Content inclusion options

Zero Configuration

  • Works out of the box with sensible defaults
  • Automatically detects posts via frontmatter plugin

Installation

pnpm add @cogita/plugin-rss

Note: This plugin depends on @cogita/plugin-posts-frontmatter to access post data.

Quick Start

The plugin will be automatically included by themes that support it:

// cogita.config.ts
import { defineConfig } from '@cogita/core';

export default defineConfig({
  site: {
    title: 'My Blog',
    description: 'Sharing my thoughts',
    url: 'https://myblog.com'
  },
  theme: 'lucid' // Theme will auto-load RSS plugin
});

Manual Configuration

// cogita.config.ts
import { defineConfig } from '@cogita/core';
import { pluginRSS } from '@cogita/plugin-rss';

export default defineConfig({
  plugins: [
    pluginRSS({
      title: 'My Blog RSS',
      description: 'Latest posts from my blog',
      link: 'https://myblog.com',
      formats: ['rss', 'atom', 'json']
    })
  ]
});

Configuration Options

interface RSSConfig {
  // Required
  title: string;           // Feed title
  description: string;     // Feed description  
  link: string;           // Website URL
  
  // Optional
  language?: string;       // Default: 'zh-CN'
  copyright?: string;      // Copyright notice
  managingEditor?: string; // Editor email
  webMaster?: string;      // Webmaster email
  
  // Output options
  formats?: ('rss' | 'atom' | 'json')[]; // Default: ['rss']
  feedPath?: string;       // Default: 'rss.xml'
  atomPath?: string;       // Default: 'atom.xml' 
  jsonPath?: string;       // Default: 'feed.json'
  
  // Content options
  maxItems?: number;       // Default: 20
  includeContent?: boolean; // Default: false
  
  // Field mapping
  customFields?: {
    author?: string;       // Frontmatter field name
    category?: string;     // Frontmatter field name
  };
}

Usage Examples

Basic RSS Feed

pluginRSS({
  title: 'Tech Blog',
  description: 'Latest technology articles',
  link: 'https://techblog.com'
})

Multi-format with Custom Paths

pluginRSS({
  title: 'My Blog',
  description: 'Personal blog updates',
  link: 'https://myblog.com',
  formats: ['rss', 'atom', 'json'],
  feedPath: 'feeds/rss.xml',
  atomPath: 'feeds/atom.xml', 
  jsonPath: 'feeds/feed.json',
  maxItems: 50
})

Custom Field Mapping

pluginRSS({
  title: 'Developer Blog',
  description: 'Software development insights',
  link: 'https://devblog.com',
  customFields: {
    author: 'writer',      // Use 'writer' field from frontmatter
    category: 'topics'     // Use 'topics' field as categories
  }
})

Generated Files

The plugin generates the following files:

  • /rss.xml - RSS 2.0 feed (if enabled)
  • /atom.xml - Atom feed (if enabled)
  • /feed.json - JSON Feed (if enabled)

HTML Integration

The plugin automatically adds discovery links to your HTML:

<head>
  <link rel="alternate" type="application/rss+xml" title="RSS Feed" href="/rss.xml" />
  <link rel="alternate" type="application/atom+xml" title="Atom Feed" href="/atom.xml" />
  <link rel="alternate" type="application/json" title="JSON Feed" href="/feed.json" />
</head>

Frontmatter Support

The plugin works with standard frontmatter fields:

---
title: "My First Post"
description: "An introduction to my blog"
date: "2024-01-15"
author: "John Doe"
categories: ["tech", "blog"]
tags: ["introduction", "welcome"]
---

Virtual Module

Access feed metadata in your components:

// Available in theme components
import { feedMeta } from 'virtual-rss-meta';

function FeedLinks() {
  return (
    <div>
      {feedMeta.rssUrl && <a href={feedMeta.rssUrl}>RSS</a>}
      {feedMeta.atomUrl && <a href={feedMeta.atomUrl}>Atom</a>}
      {feedMeta.jsonUrl && <a href={feedMeta.jsonUrl}>JSON</a>}
    </div>
  );
}

TypeScript Support

Full TypeScript support with exported types:

import type { RSSConfig, FeedMeta } from '@cogita/plugin-rss';

Troubleshooting

No Posts in Feed

  • Ensure @cogita/plugin-posts-frontmatter is loaded first
  • Check that posts exist in your posts directory
  • Verify frontmatter format is valid

Feed URLs Not Working

  • Check that your link configuration is correct
  • Ensure the build completed successfully
  • Verify feed files exist in output directory

Examples

See the plugin design document for detailed architecture and more examples.

License

MIT License. See LICENSE for details.

Contributing

Contributions welcome! Please read our Contributing Guide.

Keywords

cogita

FAQs

Package last updated on 04 Nov 2025

Did you know?

Socket

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.

Install

Related posts