1
0
mirror of synced 2025-12-20 02:19:14 -05:00

speed up link checker on PR (#32992)

This commit is contained in:
Peter Bengtsson
2022-11-28 23:10:22 +01:00
committed by GitHub
parent 52e4019890
commit 9c47ca166e
4 changed files with 40 additions and 14 deletions

View File

@@ -24,14 +24,6 @@ import wrapInElement from './plugins/wrap-in-element.js'
import doctocatLinkIcon from './doctocat-link-icon.js'
const graphql = HighlightjsGraphql.definer
// The rewrite-asset-urls plugin is nice because it makes the `<img src=...>`
// tags use unique URLs so they can be aggressively cached in the
// CDN. But it might not always make sense to bother. For example, in
// some CI where you're rendering lots of content and don't care
// about aggressive CDN caching at all. E.g. Actions that do link checking
// on rendered HTML.
const DISABLE_REWRITE_ASSET_URLS = JSON.parse(process.env.DISABLE_REWRITE_ASSET_URLS || 'false')
export default function createProcessor(context) {
return unified()
.use(process.env.COMMONMARK ? markdownNext : markdown)
@@ -52,7 +44,21 @@ export default function createProcessor(context) {
})
.use(raw)
.use(wrapInElement, { selector: 'ol > li img', wrapper: 'span.procedural-image-wrapper' })
.use(DISABLE_REWRITE_ASSET_URLS ? null : rewriteImgSources)
.use(rewriteImgSources)
.use(rewriteLocalLinks, {
languageCode: context.currentLanguage,
version: context.currentVersion,
})
.use(html)
}
export function createMinimalProcessor(context) {
return unified()
.use(process.env.COMMONMARK ? markdownNext : markdown)
.use(process.env.COMMONMARK ? gfm : null)
.use(remark2rehype, { allowDangerousHtml: true })
.use(slug)
.use(raw)
.use(rewriteLocalLinks, {
languageCode: context.currentLanguage,
version: context.currentVersion,