Move the rewriteLocalLinks behavior to an AST pipeline plugin (#17550)
* 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
This commit is contained in:
@@ -10,8 +10,9 @@ const html = require('rehype-stringify')
|
||||
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')
|
||||
|
||||
module.exports = function createProcessor () {
|
||||
module.exports = function createProcessor (context) {
|
||||
return unified()
|
||||
.use(markdown)
|
||||
.use(remarkCodeExtra, { transform: codeHeader })
|
||||
@@ -21,5 +22,6 @@ module.exports = function createProcessor () {
|
||||
.use(autolinkHeadings, { behavior: 'wrap' })
|
||||
.use(highlight, { languages: { graphql }, subset: false })
|
||||
.use(raw)
|
||||
.use(rewriteLocalLinks, { languageCode: context.currentLanguage, version: context.currentVersion })
|
||||
.use(html)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user