GrapesJS / export

Export GrapesJS templates in a zip archive

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multi-Page Support

kyng-cytro opened this issue · comments

Using this plugin, I noticed it only exports the active page. Could you work around making it all pages?

Bump
---edit---
Recanting my bump because it's already a feature.

root can be a function so you can use a configuration like below:

           'grapesjs-plugin-export': {
                root(ed) { 
                    const all = ed.Pages.getAll();
                    const pages = {};
                    const css = {};
                    all.map(page => {
                        pages[(page.get('name') || page.id) + '.html'] = '<!doctype html>' +
                            '<html lang="en">' +
                            '<head>' +
                            '<meta charset="utf-8">' +
                            '<link rel="stylesheet" href="/css/style-' + page.id + '.css">' +
                            '</head>' +
                            '<body>' +
                            page.getMainComponent().toHTML() +
                            '</body>' +
                            '</html>';
                        css['style-' + page.id + '.css'] = editor.CodeManager.getCode(page.getMainComponent(), 'css')
                    });
                    return {
                        css: {
                            ...css
                        },
                        ...pages
                    }
                }
            }

Credit: Juggernaut, via the GrapesJS discussions area.