How to use @webiny/api-page-builder - 2 common examples

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;
github webiny / webiny-js / examples / functions / code / api-service-page-builder / src / handler.js View on Github external
export const handler = async (event: Object, context: Object) => {
    if (!apolloHandler) {
        const config = await createConfig();
        const plugins = new PluginsContainer([
            securityPlugins,
            i18nPlugins,
            pageBuilderPlugins(config),
            mailchimpPlugins(config),
            gtmPlugins(config),
            cookiePolicyPlugins(config)
        ]);

        const { handler } = await createHandler({ plugins, config });
        apolloHandler = handler;
    }

    return apolloHandler(event, context);
};

@webiny/api-page-builder

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

MIT
Latest version published 8 days ago

Package Health Score

75 / 100
Full package analysis

Similar packages