VuePress Plugin Feed
RSS, Atom, and JSON feeds generator plugin for VuePress 1.x
Install
$ npm install -D vuepress-plugin-feed
$ yarn add -D vuepress-plugin-feed
Usage
Add vuepress-plugin-feed
in your site or theme config file.
See official docs on using a plugin
const feed_options = {
canonical_base: 'https://webmasterish.com',
};
module.exports = {
plugins: [
[ 'feed', feed_options ]
]
}
Page frontmatter
Page frontmatter.feed
is optional. It can be used to override the defaults.
Check the Page class
for more details.
---
title: Page Title
feed:
enable: true
title: Title used in feed
description: Description used in feed
image: /public/image.png
author:
-
name: Author
email: author@doamin.tld
link: http://doamin.tld
contributor:
-
name: Contributor
email: contributor@doamin.tld
link: http://doamin.tld
---
How pages are added as feed items
A page is auto added as a feed item if one the following conditions is met:
frontmatter.feed.enable === true
frontmatter.type === 'post'
- it resides in whatever the
posts_directories
are set to (the defaults are blog
and _posts
)
if you need to exclude a particular page that meets one of the conditions above,
you can use frontmatter.feed.enable === false
.
Details on how pages are filtered can be found in PLUGIN.is_feed_page()
.
The PLUGIN.is_feed_page()
function is the default way of filtering the pages,
you can override it using is_feed_page
option (see Options section below).
Options
See Plugin Option API official docs
Default options
You can override default options in 2 ways:
- Global plugin options set in
.vuepress/config.js
or .vuepress/theme/index.js
as described in Usage - Individual page/post
frontmatter
as shown in Page frontmatter
const {
title,
description
} = context.getSiteData ? context.getSiteData() : context;
const feed_options = {
title,
description,
generator: PLUGIN.homepage,
};
const default_options = {
canonical_base: '',
feed_options,
feeds: {
rss2: {
enable : true,
file_name : 'rss.xml',
head_link : {
enable: true,
type : 'application/rss+xml',
title : '%%site_title%% RSS Feed',
}
},
atom1: {
enable : true,
file_name : 'feed.atom',
head_link : {
enable: true,
type : 'application/atom+xml',
title : '%%site_title%% Atom Feed',
}
},
json1: {
enable : true,
file_name : 'feed.json',
head_link : {
enable: true,
type : 'application/json',
title : '%%site_title%% JSON Feed',
}
},
},
description_sources: [
'frontmatter',
'excerpt',
/^((?:(?!^#)(?!^\-|\+)(?!^[0-9]+\.)(?!^!\[.*?\]\((.*?)\))(?!^\[\[.*?\]\])(?!^\{\{.*?\}\})[^\n]|\n(?! *\n))+)(?:\n *)+\n/gim,
/<p(?:.*?)>(.*?)<\/p>/i,
],
image_sources: [
'frontmatter',
/!\[.*?\]\((.*?)\)/i,
/<img.*?src=['"](.*?)['"]/i,
],
posts_directories: ['/blog/', '/_posts/'],
is_feed_page: PLUGIN.is_feed_page,
count: 20,
sort: entries => entries,
};
Reference
Related Plugins
License
MIT © webmasterish