Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
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);
};