Skip to content

Commit

Permalink
feat: introduce data property
Browse files Browse the repository at this point in the history
  • Loading branch information
manniL committed Jan 12, 2019
1 parent a986c9a commit 23e819e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default {
async create (feed) {}, // The create function (see below)
cacheTime: 1000 * 60 * 15, // How long should the feed be cached
type: 'rss2', // Can be: rss2, atom1, json1

data: ['Some additional data'] //will be passed as 2nd argument to `create` function
}
]
//...
Expand Down
2 changes: 1 addition & 1 deletion lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async function createFeed (feedOptions, callback) {

const feed = new Feed()
try {
await feedOptions.create.call(this, feed)
await feedOptions.create.call(this, feed, feedOptions.data)
feed.options = Object.assign({ generator: 'https://github.com/nuxt-community/feed-module' }, feed.options)
} catch (err) /* istanbul ignore next */ {
logger.error(err)
Expand Down
5 changes: 3 additions & 2 deletions test/fixture/configs/object_rss.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ module.exports = {
},
modules: ['@@'],
feed: {
create (feed) {
data: { title: 'Feed Title' },
create (feed, data) {
feed.options = {
title: 'Feed Title',
title: data.title,
description: 'This is my personal feed!',
id: 'http://example.com/',
link: 'http://example.com/',
Expand Down

0 comments on commit 23e819e

Please sign in to comment.