Giter VIP home page Giter VIP logo

feed-module's People

Contributors

ericlemieux avatar gangsthub avatar isoppp avatar kimulaco avatar lecoupa avatar mannil avatar nicopennec avatar rclement avatar renovate[bot] avatar ricardogobbosouza avatar shooontan avatar zzzzbw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

feed-module's Issues

feat: generate feed link options based on `path`

In the example you specify path: '/feed.xml' but then in the create function there's a link option for the feed which seems redundant -- maybe have that link automatically derived from the path and current site url?

feed output in static folder

Why is the plugin writing the feeds into the static folder?
I would expect the files to only show up in the dist folder.

Invalid encoding

I'm using Cyrillic

feed: [
    {
      path: '/news.xml',
      async create(feed) { 
        feed.options = {
          title: 'Популярные новости России и мира',
          link: 'http://site.ru/feed.xml',
          description: 'Новости России и мира на сайте site.ru',
        }
        feed.addContributor({
          name: 'Команда проекта site.ru',
          email: 'support@ site.ru',
          link: 'http://site.ru/'
        })
      },
      cacheTime: 1000 * 60 * 15, // 15 min
      type: 'rss2'
    }
  ],

When I look feed in SRWare Iron browser, they show this:
http://take.ms/6nnGeK
How is this fixed?

Question: What is the feed-module for?

This module looks interesting but I'm not sure what it's for. What is the benefit of this feed package versus calling axios to retrieve feeds directly?
Is caching the only benefit here?

  1. How is the feed retrieved periodically? Also
  2. What happens when the cache expires and I am On a page using the feed? What happens when the cache expires and I am NOT on a page using the feed?

Example typo

Where you have:

  const posts = await axios.get('https://blog.lichter.io/posts/').data

Should be:

  const posts = (await axios.get('https://blog.lichter.io/posts/')).data

i.e. extra parens around the await/get so it resolves before you try accessing .data (as per other examples below it)

Can I add multiple configuration?

image

In production mode when I deploy /products.xml or /products/feed or whatever, doesn't work at all it only accept /feed. It works in development but in production only /feed url work. When you do /feed/products it fallbacks to /feed still.

pubdate not visible

I saw that the feeder module doesn't generate a tag in the RSS XML. Is it possible to do this.
I looked around for a bit but couldn't find a way to realise this. Is it possible to add this feature in a future release?

unclear documentation

The top level configuration works as expected:

  modules: [
    ['@nuxtjs/feed', {
    }],
  ],
  feed: [
    {
     path: '/feed.xml',
     async create (feed) {},
     cacheTime: 1000 * 60 * 15,
     type: 'rss2',
     data: ['Some additional data']
    }
  ],

Moving this into the other section as the docs suggest:

  modules: [
    ['@nuxtjs/feed', {
        path: '/feed.xml',
        async create (feed) {},
        cacheTime: 1000 * 60 * 15,
        type: 'rss2',
        data: ['Some additional data']
    }],
  ],

gives

Cannot read property 'factory' of undefined                                                                                     17:19:11

  at ModuleContainer.feed (node_modules/@nuxtjs/feed/lib/module.js:24:27)
  at ModuleContainer.addModule (node_modules/@nuxt/core/dist/core.js:177:34)
  at promise.then (node_modules/@nuxt/utils/dist/utils.js:1664:43)
  at process.runNextTicks [as _tickCallback] (internal/process/next_tick.js:47:5)
  at Function.Module.runMain (internal/modules/cjs/loader.js:804:11)
  at internal/main/run_main_module.js:21:11

Checking the source and logging what this.options contains it seems like only the top level config is supported.

Documentation on integrating nuxt/feed with nuxt/content?

I currently have a blog on my website that is generated with nuxt/content. I've been trying o add nuxt/feed with this configuration:

feed: [
  {
    path: '/feed.xml', // The route to your feed.
    async create (feed) {
      feed.options = {
        title: 'Jack Domleo - blog',
        link: 'https://jackdomleo.dev/feed.xml',
        description: 'Feed for Jack Domleo\'s blog.'
      }
     
      const posts = await this.$content('blog', { deep: true }).only(['title', 'body', 'date', 'slug', 'description', 'readingTime', 'hashtags']).sortBy('date', 'desc').fetch();
      posts.forEach(post => {
        feed.addItem({
          title: post.title,
          id: post.slug,
          link: post.slug,
          description: post.description,
          content: post.body
        })
      })
     
      feed.addCategory('Nuxt.js')
     
      feed.addContributor({
        name: 'Jack Domleo',
        link: 'https://jackdomleo.dev'
      })
    },
    cacheTime: 1000 * 60 * 15, // How long should the feed be cached
    type: 'rss2', // Can be: rss2, atom1, json1
    data: [''] // Will be passed as 2nd argument to `create` function
  }
]

When serving the website locally, it fails with ERROR this.$content is not a function. However, the nuxt/content documentation states that this method is the way to fetch the content.

Can you offer any guidance? Thank you in advance!!

Declarations and tags for a podcast feed

I'd like to be able to use this module to be able to create an RSS feed that can be used for podcast syndication.

I might be overlooking something, but there are two big barriers to this that I see;

  1. The declaration at the beginning.
  2. The named tags with a : in them, for example itunes:image

There's more info about the spec for a podcast feed here - https://support.google.com/podcast-publishers/answer/9889544?hl=en

I think this falls into the category of "big ask", but I'd love to know if it's possible!

Dynamically route

How to redo the module to add dynamic paths?
I took addServerMiddleware as a basis and added an express handler. But I do not understand how to cache dynamic paths. Why do we need the following code:

    this.nuxt.hook('generate:done', async () => {
      const xmlGeneratePath = resolve(this.options.rootDir, join(this.options.generate.dir, feedOptions.path))

      writeFileSync(xmlGeneratePath, await feedCache.get(index))
    })

Unable to generate Feed Item content from SSR generated static page

Hi,

First:
Thank you for the module!

What works:
I am using yarn generate to build a static site and was able to get a basic feed xml to be generated when calling yarn generate, adding items to the feed also works.

My Problem:
I am unable to figure out how I am supposed to fill the 'content' property of each item in the feed. I simply want to fill the atom feed with the contents of server side rendered pages, nothing special - but I can't figure out how I can do that.

The examples that I found only call some external APIs and use that result as the content.
Well - in theory - I could spin up a second instance, e.g. start nuxt in dev mode so that an http request is served while generate runs (if the dev server wouldn't crash when yarn generate is running) but that's pretty hacky of course because the content could be out of sync, the ports could change, etc. But this sound wacky for this pretty basic use case.

My Expectation:
I guess that there is a simple function in this module for this default use case that I totally overlooked, but I can't find it. :-?
Can somebody point me in the right direction?
Thanks!

Take care,
Martin

Upgrade Feed dependency

Feed is on v4.1.0 already. The latest version allows us to add categories to feed rss2 and also a lodash version boost to 4.17.15 fixing vulnerability issues

Cannot read property 'factory' of undefined

What is wrong with this config? it follows the docs but i get:

TypeError: Cannot read property 'factory' of undefined

modules: [
    ['@nuxtjs/feed', {
      path: '/feed.xml', // The route to your feed.
      async create(feed) {
        feed.options = {
          title: 'Some blog RSS Feed',
          link: 'https://someblog.sh/feed.xml',
          description: 'Latest entries on Some Blog'
        }
        const posts = await (axios.get(`${process.env.HEROKU_BACKEND_API_URL}/api/posts`)).data
        posts.forEach(post => {
          feed.addItem({
            title: post.title,
            id: post.slug,
            link: post.slug,
            content: post.content
          })
        })
      },
      cacheTime: 1000 * 60 * 15, // How long should the feed be cached
      type: 'rss2', // Can be: rss2, atom1, json1
    }],
]

How to generate <dc:creator>

I'm trying to generate an RSS feed and see that the standards are quite messed up. Does this module support dc:module, an alternative to 'author' used by a few aggregators like Flipboard? I tried looking up the documentation for the feed module, but there's no mention of it. Is there any workaround?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository. View logs.

  • WARN: Using npm packages for Renovate presets is now deprecated. Please migrate to repository-based presets instead.

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/ci.yml
  • actions/setup-node v1
  • actions/cache v1
  • codecov/codecov-action v1
npm
package.json
  • async-cache ^1.1.0
  • consola ^2.12.1
  • feed ^4.2.0

  • Check this box to trigger a request for Renovate to run again on this repository

Favicon missing when subscribing from RSS-readers.

Here's a link to my nuxt-config.js in the repository I'm having trouble with.
The feed itself works as it should but whenever I or someone else wants to subscribe from any RSS reader, the favicon never shoes up and gets replaced by a dummy icon instead.

Here are some links for troubleshooting:

Is it a bug in the module or have I configured something wrong?
I've tried changing things around in so many ways, I'm running out of ideas at this point.

The basic exemple of this module not working

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 :/

utf-8 encoding and response headers

I noticed when comparing the output of the plugin pulling JSON from a WordPress site vs the WP site's own RSS feed that maybe the encoding and headers aren't 100% correct.

For example […] (the "read more" link) in the WordPress feed display as […] with this plugin.

So I looked at the response headers and I see that WP uses content-type: application/rss+xml; charset=UTF-8 while this plugin uses Content-Type: application/rss+xml -- the charset part is missing.

Also, the feed with this plugin shows up as a standard html page not an xml document -- I'm using a colour inverter with Chrome https://chrome.google.com/webstore/detail/dark-reader/eimadpbcbfnmbkopoojfekhnkhdbieeh?hl=en and the feed from this plugin shows up with inverted colours vs the WP feed which shows up as black text on a white background, so this gave me the clue that the browser might be receiving this plugin's feed as HTML not RSS/XML.

Nuxt generate fails with version 2.0.0

Hi,

After migrating to version 2.0.0, I can use nuxt generate successfully on my local machine.
However, when running CI/CD pipelines on GitHub Actions, the generation always fails with the same error:

> nuxt-ts generate

[fatal] ENOENT: no such file or directory, open '/home/runner/work/***/***/dist/feed/articles/rss.xml'
  at Object.openSync (fs.js:458:3)
  at writeFileSync (fs.js:1279:35)
  at name (node_modules/@nuxtjs/feed/lib/module.js:36:7)
  at Nuxt.callHook (node_modules/hable/src/hable.js:65:11)
  at Generator.generate (node_modules/@nuxt/generator/dist/generator.js:53:5)
  at Object.run (node_modules/@nuxt/cli/dist/cli-generate.js:107:24)
  at NuxtCommand.run (node_modules/@nuxt/cli/dist/cli-index.js:2759:7)
resize:  can't open terminal /dev/tty

   ╭──────────────────────────────────────────────────────────────────────────────────────────╮
   │                                                                                          │
   │   ✖ Nuxt Fatal Error                                                                     │
   │                                                                                          │
   │   Error: ENOENT: no such file or directory, open                                         │
   │   '/home/runner/work/***/***/dist/feed/articles/rss.xml'   │
   │                                                                                          │
   ╰──────────────────────────────────────────────────────────────────────────────────────────╯

It seems related to the execution context of GitHub Actions virtual machines (ubuntu-latest) and of course I cannot reproduce the error anywhere. Reverting to @nuxtjs/feed version 1.1.0 immediately fixes the build.

Any ideas on what's going on? Could it be related to the recent switch to using fs.writeFileSync in @nuxtjs/feed/lib/module.js? (8832f39)

Let me know if I can provide some more help.
Thanks!

Context:

  • "nuxt": "^2.12.2"
  • "@nuxtjs/feed": "^2.0.0"

Support adding 'media:content' in feed items

I'm not sure if this is a feature request or a documentation request, but it would be great if there was a documented way of adding media images to an <item> tag.

If we take this simple usage example with nuxt-content from an example ./nuxt.config.js:

feed() {
    const baseUrlArticles = 'https://foo.com/blog'
    const baseLinkFeedArticles = '/'
    const feedFormats = {
      rss: { type: 'rss2', file: 'rss.xml' },
      json: { type: 'json1', file: 'feed.json' },
    }
    const { $content } = require('@nuxt/content')

    const createFeedArticles = async function (feed) {
      feed.options = {
        title: 'Foo.com Blog',
        description: 'Some description',
        link: baseUrlArticles
      }
      const articles = await $content('blog').fetch()

      articles.forEach((article) => {
        const url = `${baseUrlArticles}/${article.slug}`
        if (article.published) {
          feed.addItem({
            title: article.title,
            id: url,
            link: url
            // (1)
          })
        }
      })
    }

I would like to add an image or media element to the item I add to the feed with the feed.addItem function call. That would seem to imply the support for the <media:content> tag within an <item>.

Like this example (from here)

<media:content width="140" url="https://i.guim.co.uk/img/media/357d1db55e1891c6c5b407dcce4916c0891bbb9a/0_67_2772_1663/master/2772.jpg?width=140&quality=85&auto=format&fit=max&s=7dc394ddddec45b6413a2f7b632131d8" />

Or this example (from here):

<media:content height="151" medium="image" url="https://static01.nyt.com/images/2021/12/28/world/28russia-memorial01/28russia-memorial01-moth.jpg" width="151"/>

In an ideal world I'd do something like:

feed.addItem({
  title: 'A title',
  id: 'https://example.com/a-title',
  link: 'https://example.com/a-title',
  media: [{
    medium: 'image',
    url: 'https://example.com/image.jpg',
    height: 151,
    width: 151
  }]
})

Which would render an item as:

<item>
<title>A title</title>
<link>https://example.com/a-title'</link>
<pubDate>Tue, 28 Dec 2021 13:02:50 +0000</pubDate>
<media:content height="151" medium="image" url="https://example.com/image.jpg" width="151"/>
</item>

Any thoughts on if this is currently possible? If not, I'd be happy to add it if the project thinks it makes sense.

If using Apollo instead of Axios?

For those of us unable to figure it out, could you explain how we'd gain access to our data for feeds if using Apollo instead of Axios?

Prismic instead of axios?

Does anyone have a solution for using $primsic (the official nuxt plugin version) with the async create (feed) {} call?

Googlenews.xml

I wondered if anyone knows if it is possible to create a different xml structure, for a googlenews.xml sitemap. for example, using the news:news tags instead of item ?
thanks

feed output is still generated before nuxt generate

Hi

I am referring to #43.
I am using v.1.1.0 of @nuxtjs/feed and v2.10.1 of nuxt.
When I generate my app, it starts by running the create function and not my normal page generation.
It is also still making a feed.xml file in my static folder.

So I think this pull is not in a new release of this module? Is this correct?
If so, could you please make a new release of this module so we can all enjoy this new feature?

Error when using feed-module

There is an error when using feed-module.

error msg:

ERROR  Nuxt error

  Error: /home/zbw/develop/web/Fame/fame-front/node_modules/@nuxtjs/feed/lib/module.js:1
  (function (exports, require, module, __filename, __dirname) { import path from 'path'
                                                                       ^^^^
  SyntaxError: Unexpected identifier

node version: v11.6.0

Rss and Json don't render author field

I added author field to items:

ideas.forEach((idea) => {
    feed.addItem({
      title: idea.title,
      id: idea.short_id,
      link: `${urlBase}/${idea.short_id}/${idea.slug}`,
      content: idea.content,
      date: new Date(idea.idea_date),
      author: idea.user.name,
    })
  })

But in the rss elements are like this:

         <item>
            <title><![CDATA[New board]]></title>
            <link>https://www.bla.com/nkkmzt/new-board</link>
            <guid>nkkmzt</guid>
            <pubDate>Sat, 23 Jul 2022 16:22:21 GMT</pubDate>
            <content:encoded><![CDATA[<p>Test</p>]]></content:encoded>
        </item>

And for JSON:

{
id: "i43be6",
content_html: "<p>Test</p>",
url: "https://www.dailyidea.com/i43be6/an-idea",
title: "An idea",
date_modified: "2022-07-23T16:34:06.000Z",
author: { }
}

I validatedidea.user.name is present and are strings.

Date issue with Nuxt Content and Feed

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?

Feature Request: Generated files log

This is a great module!

When it was generated, I think it more kindness to display the generated feed file on the console.
For example, I want to display the following log with reference to @nuxtjs/sitemap.

i Generating feeds                                                                                                                                                  
✔ Generated /feed.xml                                                                                                                                               
✔ Generated /article.xml

If you have ideas, please.
I will create a PR for this issue.

Integration in other modules

I would really like to integrate this module into wp-nuxt.

I can't get it working using this.requiredModule:

this.requireModule(['@nuxtjs/feed', Object.assign({}, options.feed, {
})])

Is this something that will be soon integrated or would that be something you would welcome a pr?

Custom fields

I wanted to have some extra fields other than the ones documented. I figured out a few by my own such as date and guid, but I still needed fields such as author and categories for each entry.
If there is already a way to set those, I could not get it right, and it is not documented I believe.

How can i setup create function?

I have defined create function in my nuxt.config.js file.
axios is not imported in nuxt.config.js and i have an error:

ReferenceError: axios is not defined

  feed: [{
      path: '/rss_export', // The route to your feed.
      async create (feed) {
        feed.options = {
          title: 'title',
          description: 'describtion',
        }

        const posts = await axios.get('http://localhost:3000/v1/news/').data

        posts.forEach(post => { 
          feed.addItem({
              title: 'test'
          })
        
          feed.addCategory('funny')
        
          feed.addContributor({
              // some details
          })
        })
      },
      cacheTime: 1000 * 60 * 15, 
      type: 'rss2' 
    }
  ],

what is the best way to setup create function? Give me code example please

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.