1
0
mirror of synced 2025-12-20 18:36:31 -05:00

DISABLE_REWRITE_ASSET_URLS for some Actions (#28165)

This commit is contained in:
Peter Bengtsson
2022-06-13 08:59:16 -04:00
committed by GitHub
parent 393065f7d4
commit 46c701b863
3 changed files with 17 additions and 1 deletions

View File

@@ -25,6 +25,14 @@ 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)
@@ -46,7 +54,7 @@ export default function createProcessor(context) {
.use(raw)
.use(rewriteLegacyAssetPaths, context)
.use(wrapInElement, { selector: 'ol > li img', wrapper: 'span.procedural-image-wrapper' })
.use(rewriteImgSources)
.use(DISABLE_REWRITE_ASSET_URLS ? null : rewriteImgSources)
.use(rewriteLocalLinks, {
languageCode: context.currentLanguage,
version: context.currentVersion,