nuxt-community / feed-module

Everyone deserves RSS, ATOM and JSON feeds!
MIT License
226 stars 36 forks source link

The basic exemple of this module not working #100

Open pirmax opened 2 years ago

pirmax commented 2 years ago

The basic exemple of this module not working...

I haven't error, but the result is:

<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
    <channel>
        <title>undefined</title>
        <link>undefined</link>
        <description>undefined</description>
        <lastBuildDate>Sat, 27 Nov 2021 11:34:25 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/nuxt-community/feed-module</generator>
    </channel>
</rss>

The code in nuxt.config.js:

feed: [
    {
      path: '/feed.xml',
      // cacheTime: 1000 * 60 * 15,
      cacheTime: -1,
      type: 'rss2',
      data: [],
      feed (feed) {
        feed.options = {
          title: 'My blog',
          link: 'https://lichter.io/feed.xml',
          description: 'This is my personal feed!'
        }
      }
    }
  ]

I very need of this module :/

apttx commented 2 years ago

Not sure if you figured this out since, but your feed(feed){} should be create(feed){}, if you want a function on a per-feed basis. You can alternatively use a function for the feed property of your nuxt config (which is an array in your code) and return an array of feed configs.

Your nuxt.config.js should be

{
  feed: [
    // ...
    create(feed) {}
  ]
}

or

{
  feed() {
    return [
      {
       // ...
        create(feed) {}
      }
    ]
  }
}