Skip to content

Commit

Permalink
render markdown in intro on map-topic pages (github#32421)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbe authored Nov 7, 2022
1 parent 827a091 commit 8f3df18
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion components/landing/TableOfContents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const TableOfContents = (props: Props) => {
</Link>
</h2>
{intro && (
<p className="f4 color-fg-muted" dangerouslySetInnerHTML={{ __html: intro }} />
<div className="f4 color-fg-muted" dangerouslySetInnerHTML={{ __html: intro }} />
)}
</li>
)
Expand Down
8 changes: 4 additions & 4 deletions middleware/contextualizers/generic-toc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -93,16 +92,17 @@ 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
let intro = null
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)
}
}

Expand Down

0 comments on commit 8f3df18

Please sign in to comment.