-
-
Notifications
You must be signed in to change notification settings - Fork 622
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
Fetch content from external sources #37
Comments
Hey @janekkkk, Nuxt Content parses markdown files on the file system on load and builds an API around the database generated from the content directory, it cannot be used on eternal sources. You're alternative seems the way to go. |
An easy solution to this is to simply fetch the external markdown files in a node script that runs before the build/export steps. Fetch (or use I do this -- and it seems to work (in my case, at least). I'm building on Netlify. No issues with this approach. |
That's really interesting — if your external database updates (e.g. you have a new blog), how does that trigger Netlify to re-run the fetch script to build that new file into content directory, and then rebuild/re-export the Nuxt site? |
I know the issue is closed, but I also wish there was a better way to use Nuxt Content's markdown features for external files. One solution is to use hmsk/frontmatter-markdown-loader, but I wish there was a way to do it using only Nuxt Content |
Here's a quick example of how to load and build the
I don't add the content loader to the Hope that helps! |
I use Strapi as an external API/auth service -- but the way I've dealt with this sort of issue with Strapi is to send a build hook when the user adds new content and then updates a "build" task. My use case for this is when new content is added or updated -- I ask users to insert a new build task (a content-type in Strapi). When they enter the new task -- a note and their initials -- Strapi sends a webhook to Netlify to initiate a build. I have a node file that runs as part of the build to update the search index. This node script generates an index for the entire site (including the new content item(s)) -- and then rebuilds everything. (I use fuse.js for the search.) This approach works great -- no issues. The only thing I need to watch are my Netlify build minutes (about 60 seconds for each site) -- but I'm managing about 15 sites this way on Netlify without issues. (These are low-traffic but critical sites -- so that's why Netlify is perfect.) |
I am still looking for this. It would be great if I can host and update my blog posts on a Github repository, instead of rebuilding the entire Nuxt project. |
I also would like to be able to host my markdown files in Firebase Cloud Storage and fetch them at runtime via an API. I already figured out hot to dynamically generate the routes. The only thing I haven't figured out is how to parse the markdown into the tag. Some of my markdown files have vue components in them, so a 3rd party API isn't a feasible option for me. |
Are you using a webook or a server hook? Would you be able to share some code if you don't mind please? |
Is your feature request related to a problem? Please describe.
I've got some articles in a database which can be accessed by a REST API. It would be great to access these articles from Nuxt Content.
Describe the solution you'd like
For example:
const { title } = await this.$content('https://some-api/article-1').only(['title']).fetch()
Describe alternatives you've considered
Instead of accessing them like above. Download markdown files to the content directory and access them in the regular way.
Thanks for all the hard work and the awesome new features!
The text was updated successfully, but these errors were encountered: