From 9f0a9c2412a1c7f91ff16146dcf701a7e05971a0 Mon Sep 17 00:00:00 2001 From: Sander Elias Date: Tue, 21 Jan 2020 14:47:57 +0100 Subject: [PATCH] Sander/add config to handled route (#206) * fix(behaviour of postrender array): makes sure the postreder array is passed correctly => { const routesToGenerate = await routeList.reduce(async (result: Promise, cur: string) => { const x = await result; - if (scullyConfig.routes[cur]) { - const postRenderers: string[] = Array.isArray(scullyConfig.routes[cur].postRenderers) - ? scullyConfig.routes[cur].postRenderers - : []; + const config = scullyConfig.routes[cur]; + if (config) { + const postRenderers: string[] = Array.isArray(config.postRenderers) ? config.postRenderers : undefined; /** adding in the postrenderes. Note that the plugin might choose to overwrite the ones that come from the config */ - const r = (await routePluginHandler(cur)).map(r => ({postRenderers, ...r})); + const r = (await routePluginHandler(cur)).map(row => + postRenderers ? {postRenderers, ...row, config} : {...row, config} + ); x.push(...r); } else if (cur.includes('/:')) { logWarn(`No configuration for route "${yellow(cur)}" found. Skipping`); @@ -27,6 +28,7 @@ export const addOptionalRoutes = async (routeList = [] as string[]): Promise