Closed joshbedo closed 4 years ago
Hi Josh, storing and loading templates is described more in details here: https://grapesjs.com/docs/modules/Storage.html#store-and-load-templates
Basically, the editor stores 2 types of data:
components
and style
, JSON result of your template. You need these to load back the data in the editor.html
and css
, HTML/CSS result of your template. This can be used to be rendered in your final page (eg. the page created by your user) but DON'T use it to load it back in the editor for editing.In short how can i render a page generated in grapejs?
Well, this depends, I'd expect you to know that at first 😅. For example, if you store the entire object in your firebase document the result might be something like this:
app.get('/pages/:id', (req, res) => {
const page = firebase.getData(req.params.id); // just an example
// Just an example of what you can return
res.send(`<html>
...
<style>${page.css}</style>
</head>
<body>
${page.html}
</body>
<html>`);
});
I've been reading a lot of the documentation and closed issues but I'm a little confused on the best approach to render a page stored in firestore.
For example I have a node.js backend using cloud functions and i was thinking i would basically have an API endpoint that pulls the page from the firestore and renders it. Is this possible? I haven't found many examples on how to render pages from the server.
In short how can i render a page generated in grapejs? So i can show a preview of the page and also have a live website using something generated by grapejs.
ex: