If it's just an endpoint, you could create an UmbracoApiController that looped through the site (but maybe not if the site is huge) and writes out a JSON representation of the published data for each page...
If you want to use Umbraco in a 'headless' way you could look at the uHeadless package:
that would give a graphQL interface for the VueJS app to call
But if it's a physical file, is it a one off import, does the VueJS app live within the Umbraco site? or on a different server, how often is the content edited? you could programmatically hook into the ContentCacheRefresherNotification Notification that fires whenever content is published, and update the file on disk with the latest content, but it doesn't seem like the best approach!
If it's just a 20 page site that doesn't get updated very often, I'd probably just use Umbraco templates, as that's the easiest way of working with Umbraco :-P (says a non-front-endy person!)
But if you want to use VueJS, then I think you have many options for how you'd like to build your site.
Having a JSON file for all the data
Hi Friends I've just started working with Umbraco, So I have a question and I don't know is it possible or not?
They asked me to make a JSON file of all the data and use it in Vue file (Fetching data)
But I don't know how to make a JSON file from the content and every time they update the content, that JSON file would be updated or not?
( I'm using the latest version on Umbraco)
Thank you
Hi Sahar
Do they want a physical file or an endpoint?
If it's just an endpoint, you could create an UmbracoApiController that looped through the site (but maybe not if the site is huge) and writes out a JSON representation of the published data for each page...
If you want to use Umbraco in a 'headless' way you could look at the uHeadless package:
https://github.com/nikcio/Nikcio.UHeadless
that would give a graphQL interface for the VueJS app to call
But if it's a physical file, is it a one off import, does the VueJS app live within the Umbraco site? or on a different server, how often is the content edited? you could programmatically hook into the ContentCacheRefresherNotification Notification that fires whenever content is published, and update the file on disk with the latest content, but it doesn't seem like the best approach!
regards
Marc
Thank you for replying Which one do you recommend? It's a website about the company with maybe 10-20 pages, and we won't update the site every day.
They just want to have Vue components and get data from the JSON file, instead of making templates in Umbraco
Best regards Sahar
Hi Sahar
If it's just a 20 page site that doesn't get updated very often, I'd probably just use Umbraco templates, as that's the easiest way of working with Umbraco :-P (says a non-front-endy person!)
But if you want to use VueJS, then I think you have many options for how you'd like to build your site.
Gridsome is a static site generator that works with VueJS and a GraphQL source for the data https://gridsome.org/ There is a post here about someone setting up gridsome with Umbraco, https://www.proworks.com/blog/archive/headless-on-umbraco-net-core-part-3-setup-graphql-api-and-connect-back-end-and-front-end I think the uHeadless plugin would turn your backoffice into a graphql provider (or there is also a paid for 'Umbraco Heartcore' software as a service paid for version of Umbraco that provides one)
Anyway if you are comfortable building a VueJS front end with GraphQL then that might be a good way to go.
Or if GraphQL is over the top, and you just want a JSON source for each page.
Then you could create an Umbraco Template for each page called RenderJSON
Which returned a JSON representation of your content for every page, eg Your Vue Component would request the data via the published URL for that page.
Or if your Vue Component lived inside your Umbraco Page Template, you could pass a JSON object to it in the template, via a
is working on a reply...