1
0
mirror of synced 2025-12-21 19:06:49 -05:00

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:
Jason Etcovitch
2021-01-29 10:36:17 -05:00
committed by GitHub
parent 8d4f3e65fe
commit 989006bab5
4 changed files with 106 additions and 12 deletions

View File

@@ -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)
}