Skip to content

Commit b7923ef

Browse files
heiskrCopilot
andauthored
perf: use Liquid-only rendering for secret scanning template (#60570)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 770ca35 commit b7923ef

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

src/article-api/transformers/secret-scanning-transformer.ts

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import type { Context, Page } from '@/types'
22
import type { PageTransformer } from './types'
33
import { load } from 'js-yaml'
44
import path from 'path'
5-
import { liquid, renderContent } from '@/content-render/index'
5+
import { liquid } from '@/content-render/index'
66
import { allVersions } from '@/versions/lib/all-versions'
77
import { loadTemplate } from '@/article-api/lib/load-template'
88
import { getSecretScanningData } from '@/secret-scanning/lib/get-secret-scanning-data'
99

1010
/**
1111
* Transformer for Secret Scanning pages.
12-
* Loads pattern data and converts secret scanning documentation into markdown format using a Liquid template.
12+
* Loads pattern data and converts secret scanning documentation into markdown format.
1313
* Used by the Article API to render Secret Scanning documentation dynamically.
1414
*/
1515
export class SecretScanningTransformer implements PageTransformer {
@@ -87,22 +87,15 @@ export class SecretScanningTransformer implements PageTransformer {
8787

8888
const intro = page.intro ? await page.renderProp('intro', context, { textOnly: true }) : ''
8989

90-
// Prepare template data
91-
const templateData: Record<string, unknown> = {
92-
page: {
93-
title: page.title,
94-
intro,
95-
},
96-
content,
97-
}
98-
99-
// Load and render template
90+
// Render the template with Liquid only — page.render() already ran
91+
// rewriteLocalLinks on all markdown links, and the regex cleanup above
92+
// only creates fragment links (e.g. #token-versions) which don't need
93+
// link rewriting. So we skip the expensive remark re-parse.
10094
const templateContent = loadTemplate(this.templateName)
101-
102-
return await renderContent(templateContent, {
95+
return await liquid.parseAndRender(templateContent, {
10396
...context,
104-
...templateData,
105-
markdownRequested: true,
97+
page: { title: page.title, intro },
98+
content,
10699
})
107100
}
108101
}

0 commit comments

Comments
 (0)