Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If using Apollo instead of Axios? #5

Open
adamkhan opened this issue Sep 5, 2018 · 8 comments
Open

If using Apollo instead of Axios? #5

adamkhan opened this issue Sep 5, 2018 · 8 comments
Labels
question Further information is requested

Comments

@adamkhan
Copy link

adamkhan commented Sep 5, 2018

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?

@manniL
Copy link
Member

manniL commented Sep 5, 2018

I'm sorry but I don’t have experience with Apollo/GraphQL. 😕

But essentially it should work similar to the axios setup (import the package of the „connection agent“, make the request, use the data“). However you have to use plain NPM packages

@adamkhan
Copy link
Author

adamkhan commented Sep 9, 2018

Thanks for the quick response. I'm just not sure how to go about doing this within nuxt.config.js rather than in a .vue component file. Well, if I figure it out I'll post here.

@manniL
Copy link
Member

manniL commented Sep 9, 2018

You are welcome!

Yeah, that's a bit tricky. But there is likely a node apollo client you could use for that, right? 🤔

@adamkhan
Copy link
Author

adamkhan commented Sep 9, 2018

I'll look into that.

What might be simpler for me as well, coming from a monolithic CMS background, is the completely different approach of creating a new layout for feeds. Though I'm not sure yet how much of the <head> tag and whether the doctype can be overridden in Nuxt...

@manniL
Copy link
Member

manniL commented Sep 9, 2018

Well, you have to provide the feeds somehow 🤷‍♂️

With this module, nuxt will take over this job. Attaching feeds into your metadata is not covered but should be easy as you can control the URLs 👍

@adamkhan
Copy link
Author

Right now this alternative approach to your feed module looks to me not possible in Nuxt, because the doctype is set in the the View, and only one View can be set it seems, ie, the one that shows the web pages, else no web site! See https://nuxtjs.org/guide/views/.

So in order to output a feed without your module, a whole new instance of Nuxt would seem to be required!

@manniL manniL added the question Further information is requested label Oct 5, 2018
@mimbo119
Copy link

mimbo119 commented Jul 15, 2021

Here's an example:

async create (feed) {
        feed.options = {
          title: 'Something',
          description: 'A RSS news feed containing the latest news of Something.',
          link: 'https://www.Something.com/rss.xml',
          feedLinks: {
            atom: 'https://www.Something.com/rss.xml'
          },
          language: 'bn-bd',
          copyright: 'Copyright 2021, Something  Limited',
          creator: 'John Doe',
          author: {
            name: 'Something (digital@Something.com)'
          },
          dc: {
            language: 'bn-bd',
          }
        }
        const feedData = []
        const fetch = require('cross-fetch')
        await fetch(process.env.GQL_API + '/graphql', {
          method: 'POST',
          headers: { 'Content-Type': 'application/json' },
          body: JSON.stringify({
            query: ` query {
              news {
                news{
                  slug
                  updatedAt
                  title
                  description
                  subtitle
                  author {
                    nameBn
                  }
                  category{
                    name
                  }
                  coverImage
                }
              }
            }`,
            variables: {}
          })
        }).then(res => res.json())
          .then((data) => {
            data.data..forEach((blog) => {
              feedData.push(blog)
            })
          })
        feedData.forEach((blog) => {
          feed.addItem({
            title: blog.title,
            link: process.env.BASEURL + `/news/${new Intl.DateTimeFormat('fr-ca').format(blog.updatedAt).replace('/', '-').replace('/', '-')}/${blog.slug}`,
            description: blog.subtitle + blog.description.replace(/(<([^>]+)>)/ig, '').trim(),
            // description: blog.description,
            published: new Date(parseInt(blog.updatedAt)),
            id: blog.slug,
            source: 'Something Limited',
            creator: blog.author.nameBn,
            content: blog.description,
            image: blog.coverImage,
            media: {
              content: blog.coverImage
            },
            author: [
              {
                name: blog.author.nameBn
              }
            ],
            category: blog.category.name
          })
        })
      },

But the problem is the feed doesnt show in a xml format version, and dc elements dont show.

@adamkhan
Copy link
Author

https://jsonfeed.org/ is a standard that more readers are handling.

@nozomuikuta nozomuikuta mentioned this issue Jul 21, 2022
28 tasks
@nozomuikuta nozomuikuta mentioned this issue Dec 14, 2022
21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants