From 8f3df18dba5e68bed216c11b5ba7fc0f9cbef965 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Mon, 7 Nov 2022 21:28:23 +0100 Subject: [PATCH] render markdown in intro on map-topic pages (#32421) --- components/landing/TableOfContents.tsx | 2 +- middleware/contextualizers/generic-toc.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/landing/TableOfContents.tsx b/components/landing/TableOfContents.tsx index 05419deb0c10..5c225bb2c2c9 100644 --- a/components/landing/TableOfContents.tsx +++ b/components/landing/TableOfContents.tsx @@ -33,7 +33,7 @@ export const TableOfContents = (props: Props) => { {intro && ( -

+

)} ) diff --git a/middleware/contextualizers/generic-toc.js b/middleware/contextualizers/generic-toc.js index 569ed661d3cb..8f149d133c09 100644 --- a/middleware/contextualizers/generic-toc.js +++ b/middleware/contextualizers/generic-toc.js @@ -60,7 +60,6 @@ export default async function genericToc(req, res, next) { if (currentTocType === 'flat' && !isOneOffProductToc) { isRecursive = false renderIntros = true - req.context.genericTocFlat = [] req.context.genericTocFlat = await getTocItems(treePage, req.context, { recurse: isRecursive, renderIntros, @@ -93,6 +92,7 @@ async function getTocItems(node, context, opts) { return await Promise.all( node.childPages.filter(filterHidden).map(async (child) => { const { page } = child + // The rawTitle never contains Markdown but it might contain Liquid const title = page.rawTitle.includes('{') ? await liquid.parseAndRender(page.rawTitle, context) : page.rawTitle @@ -100,9 +100,9 @@ async function getTocItems(node, context, opts) { if (opts.renderIntros) { intro = '' if (page.rawIntro) { - intro = page.rawIntro.includes('{') - ? await liquid.parseAndRender(page.rawIntro, context) - : page.rawIntro + // The intro can contain Markdown even though it might not + // contain any Liquid. + intro = await page.renderProp('rawIntro', context) } }