How to use the @webiny/api-page-builder/plugins/graphql/pageResolvers/listPublishedPages.listPublishedPages function in @webiny/api-page-builder

To help you get started, we’ve selected a few @webiny/api-page-builder examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webiny / webiny-js / packages / api-page-builder / src / plugins / graphql / menuResolvers / prepareMenuItems.js View on Github external
async ({ context, item }) => {
                switch (item.type) {
                    case "page": {
                        if (!context.distinctParents.loaded) {
                            const ids = Object.keys(context.distinctParents.data);

                            await listPublishedPages({
                                args: { parent: ids },
                                context
                            }).then(results => {
                                for (let i = 0; i < results.length; i++) {
                                    let { title, url, parent: id } = results[i];
                                    context.distinctParents.data[id] = { id, title, url };
                                }
                            });
                        }

                        const page = context.distinctParents.data[item.page];
                        if (page) {
                            // First try to use the title set on the menu item. If none, use page title.
                            Object.assign(item, page, { title: item.title || page.title });
                        } else {
                            item.__cleanup__ = true;

@webiny/api-page-builder

The API for the Webiny Page Builder (webiny-app-page-builder) app.

MIT
Latest version published 12 days ago

Package Health Score

78 / 100
Full package analysis

Similar packages