nuxt / content

The file-based CMS for your Nuxt application, powered by Markdown and Vue components.
https://content.nuxt.com
MIT License
3.13k stars 626 forks source link

lazy load content items for custom drivers #1341

Open bloodf opened 2 years ago

bloodf commented 2 years ago

Is your feature request related to a problem? Please describe

When using nuxt-content to fetch articles from dev.to, with a custom driver. The current process will try to fetch all the items in the first call, and we have to add the file extension direct inside the key of the items list. For example ${key}.md

This process triggers API throttling and blocks the usage of the nuxt-content + custom drivers.

Describe the solution you'd like

Ideally, if we could add an option in the driver object, which it describes as lazy loaded content, the unstorage will behave the same, but only fetch the item's content when it's requested by the content API.

Also declaring the type of file extension or transformer that will be used in the handling of the getItem will remove the need to make the driver create keys as ${key}.md, because when fetching from the API the URL becomes https://dev.to/api/articles/955318.md$

I've created a repository with the custom driver and the error of multi-loading.

https://github.com/bloodf/nuxt_content_lazyload_driver

Describe alternatives you've considered

Another alternative for this is creating a component that takes a markdown content plain in string and renders it, using the nuxt-content behavior.

Or have an API that receives the string a post param and returns the markdown object used by nuxt-content so we can use the internal MarkdownRenderer component to render.

Additional context

This usage case it's good for implementing a headless CMS with nuxt-content, where open drivers to blog platforms like dev.to, hackernoon and other markdown blogs, which will enable people to use it, and use the platforms as purely "Editors"

imkonsowa commented 1 year ago

Have you ever tackled this? I'm looking for a solution where I can fetch plain MD from my server and make nuxt-content render it. Or even render the json body of MD and store it in my DB and make ContentRender component to render it!