1.0.0 • Published 3 years ago
@guillermodlpa/next-rss v1.0.0
next-rss
next-rss is an RSS generation library for next.js apps.
Installation
npm install @guillermodlpa/next-rssUsage
Create the next-rss.js file in your project's root directory.
module.exports = {
siteTitle: 'example web site',
siteDescription: 'example web site rss feed',
siteLanguage: 'en',
siteCopyright: '©Tadashi Yamazaki',
siteUrl: 'http://example.com',
outDir: 'public',
postsDir: 'posts',
createFeedItem: (pageProps) => ({
title: pageProps.postData.title,
id: `${config.siteUrl}/${config.postsDir}/${pageProps.postData.id}`,
link: `${config.siteUrl}/${config.postsDir}/${pageProps.postData.id}`,
date: new Date(pageProps.postData.date)
}),
}Build your Next.js project, and then run this command
npx next-rssYou can add it to the postbuild scripts in package.json to execute it automatically.
Details
- The script will parse the build manifests to obtain pages in the
[postsDir]folder. - The function
createFeedItemwill produce each feed item and it can be customized to set additional parameters. - The function
createFeedItemreceives each page props and thenext-rssconfig itself.
1.0.0
3 years ago