nuxt-community / feed-module

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

Date issue with Nuxt Content and Feed #88

Closed jessequinn closed 3 years ago

jessequinn commented 3 years ago

Following the example found here When i work with the createdAt property of an article, regardless of rss, atom or json, i get the following error:

item.date.toISOString is not a function  
      const articles = await $content('articles')
        .only(['title', 'description', 'slug', 'author', 'createdAt'])
        .sortBy('createdAt', 'desc')
        .fetch()

      articles.forEach((article) => {
        const url = `${baseUrlArticles}/${article.slug}`

        feed.addItem({
          title: article.title,
          id: url,
          link: url,
          date: article.createdAt,
          // date: new Date(article.createdAt).toLocaleDateString('en', {
          //   year: 'numeric',
          //   month: 'long',
          //   day: 'numeric',
          // }),
          description: article.description,
          content: article.description,
          author: article.author,
        })
      })

Any ideas how to handle this?

manniL commented 3 years ago

Try date: new Date(article.createdAt)

jessequinn commented 3 years ago

thanks, appears to work with my custom date publishedAt.