Remove cheerio from Page#render (#17566)
* Write our plugin
* Include it
* Move the RegEx
* Don't rewriteLocalLinks with cheerio anymore
* Process after HTML ast is generated
* Use the same logic as before, just to see if it'll pass
* Don't require languageCode/version
* Only work on local links
* Needs an href
* Only update href if there's a new one to use
* Check for node.properties
* Some links are just mean
* Move use-english-headings to be a plugin
* Bail if no englishHeadings were passed
* Install rehype-wrap
* Wrap ol > li img in div.procedural-image-wrapper
* Test for platform without cheerio
* Use a plugin for rewriteAssetPathsToS3
* Remove cheerio from page.render
* Fix require paths
* SImplify
* Fix some 🐛s
* Use our own rehype-wrap
* Move rewriteAssetPathsToS3 after HTML AST
* Remove some console logs
* Fix check for includesPlatformSpecificContent
* Rename ast => tree
This commit is contained in:
@@ -11,6 +11,9 @@ const graphql = require('highlightjs-graphql').definer
|
||||
const remarkCodeExtra = require('remark-code-extra')
|
||||
const codeHeader = require('./plugins/code-header')
|
||||
const rewriteLocalLinks = require('./plugins/rewrite-local-links')
|
||||
const useEnglishHeadings = require('./plugins/use-english-headings')
|
||||
const rewriteAssetPathsToS3 = require('./plugins/rewrite-asset-paths-to-s3')
|
||||
const wrapInElement = require('./plugins/wrap-in-element')
|
||||
|
||||
module.exports = function createProcessor (context) {
|
||||
return unified()
|
||||
@@ -19,9 +22,12 @@ module.exports = function createProcessor (context) {
|
||||
.use(emoji)
|
||||
.use(remark2rehype, { allowDangerousHTML: true })
|
||||
.use(slug)
|
||||
.use(useEnglishHeadings, context)
|
||||
.use(autolinkHeadings, { behavior: 'wrap' })
|
||||
.use(highlight, { languages: { graphql }, subset: false })
|
||||
.use(raw)
|
||||
.use(rewriteAssetPathsToS3, context)
|
||||
.use(wrapInElement, { selector: 'ol > li img', wrapper: 'div.procedural-image-wrapper' })
|
||||
.use(rewriteLocalLinks, { languageCode: context.currentLanguage, version: context.currentVersion })
|
||||
.use(html)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user