Git Product home page Git Product logo

gatsby-plugin-advanced-feed's Introduction

@fec/gatsby-plugin-advanced-feed

Gatsby plugin that generates RSS 2, Atom and JSON feeds for your site.

Unit tests Integration tests

Made by ๐Ÿ‘จโ€๐Ÿ’ป Florian Eckerstorfer in ๐ŸŽก Vienna, Europe.

Table of Contents

  1. Features
  2. Differences to gatsby-plugin-feed
  3. Installation & Setup
  4. Configuration
  5. Code of Conduct
  6. Change log
  7. License

Features

  • Generates RSS 2.0
  • Generates Atom 1.0
  • Generates JSON Feed 1.0
  • Supports multiple feeds

Differences to gatsby-plugin-feed

  • โœ… Supports Atom 1.0 and JSON Feed 1.0 in addition to RSS 2.0
  • โœ… More options to customize feed description, copyright, author, etc
  • โŒ Does not support serialize and query options (yet)

Installation & Setup

First you need to install the plugin with NPM or Yarn:

npm install @fec/gatsby-plugin-advanced-feed --save
yarn add @fec/gatsby-plugin-advanced-feed

Versions 2.x of this plugin are tested with Gatsby v3, you might need to use @fec/gatsby-plugin-advanced-feed@1 if you are still using Gatsby v2.

Next you need add the plugin to the plugins list in gatsby-config.js:

// ./gatsby-config.js
module.exports = {
  // ...
  plugins: [
    // ...
    '@fec/gatsby-plugin-advanced-feed',
  ],
};

โš ๏ธ Feeds are only generated on gatsby build, when running the local development server (gatsby develop) no feeds will be generated.

Configuration

You can configure @fec/gatsby-plugin-advanced-feed. The following example contains all configuration options and their default value:

// ./gatsby-config.js
module.exports = {
  // ...
  plugins: [
    // ...
    {
    resolve: '@fec/gatsby-plugin-advanced-feed',
    options: {
      feeds: [
        {
          // Configure the feed; smart defaults are choosen if not set
          author: undefined,      // default: site.siteMetadata.author
          copyright: undefined,   // default: "All rights reserved {year}, {site.siteMetadata.author}"
          description: undefined, // default: site.siteMetadata.description
          email: false,           // default: false โžž no email in feed; undefined โžž site.siteMetadata.email
          id: undefined,          // default: site.siteMetadata.siteUrl
          link: undefined,        // default: site.siteMetadata.siteUrl
          title: undefined,       // default: site.siteMetadata.title

          // Add <link> tags in <head> to feeds
          createLinkInHead: true, // `true` for all pages or regular expression to match pathnames

          // Number of articles to include in feed
          limit: 10,

          // Include all pages which `fileAbsolutePath` matches this regular expression
          match: '^/blog/',

          // File names of generated feeds
          output: {
            rss2: 'rss.xml',
            atom: 'atom.xml',
            json: 'feed.json',
          },
        }
      ],
    },
  ],
};

Include only in certain pages

@fec/gatsby-plugin-advanced-feed allows you to link the feeds in the <head> or your page. This can be configured on a per-feed basis. If the option createLinkInHead for a feed is true the <link> will be included on all pages. You can include the <link> only for certain pages by specifying a regular expression.

In the following example the <link> tags will only be inserted on all pages which pathname matches the regular expression /^\/blog/:

// ./gatsby-config.js
module.exports = {
  // ...
  plugins: [
    // ...
    {
      resolve: '@fec/gatsby-plugin-advanced-feed',
      options: {
        feeds: [
          createLinkInHead: /^\/blog/,
        ]
      }
    }
  ],
};

Code of Conduct

See CODE_OF_CONDUCT

Change log

See CHANGELOG

License

See LICENSE

gatsby-plugin-advanced-feed's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar florianeckerstorfer avatar gretchenfitze avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

gatsby-plugin-advanced-feed's Issues

Feed links don't handle leading slashes consistently

If you use a path as part of the output filenames, such as:

            output: {
              rss2: '/foo/rss.xml',
              atom: '/foo/atom.xml',
              json: '/foo/feed.json',
            },

This is handled well by this:
https://github.com/florianeckerstorfer/gatsby-plugin-advanced-feed/blob/main/src/gatsby-ssr.js#L26-L34

But not by this:
https://github.com/florianeckerstorfer/gatsby-plugin-advanced-feed/blob/main/src/gatsby-node.js#L39-L43

Resulting in feed.json having:

    "feed_url": "https://example.com//foo/feed.json",

(note the double slashes)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.