зеркало из https://github.com/github/docs.git
Make rewriteLocalLinks Markdown plugin async (#36763)
This commit is contained in:
Родитель
c6eb4a7fee
Коммит
22b517e26a
|
@ -46,9 +46,8 @@ export default function rewriteLocalLinks(context) {
|
|||
// There's no languageCode or version passed, so nothing to do
|
||||
if (!currentLanguage || !currentVersion) return
|
||||
|
||||
return async (tree) => {
|
||||
const promises = []
|
||||
|
||||
return async function (tree) {
|
||||
const nodes = []
|
||||
visit(tree, matcherInternalLinks, (node) => {
|
||||
const newHref = getNewHref(node, currentLanguage, currentVersion)
|
||||
if (newHref) {
|
||||
|
@ -57,7 +56,7 @@ export default function rewriteLocalLinks(context) {
|
|||
for (const child of node.children) {
|
||||
if (child.value) {
|
||||
if (AUTOTITLE.test(child.value)) {
|
||||
promises.push(getNewTitleSetter(child, node.properties.href, context))
|
||||
nodes.push({ href: node.properties.href, child })
|
||||
} else if (process.env.NODE_ENV !== 'production') {
|
||||
// Throw if the link text *almost* is AUTOTITLE
|
||||
if (
|
||||
|
@ -89,11 +88,7 @@ export default function rewriteLocalLinks(context) {
|
|||
})
|
||||
}
|
||||
|
||||
if (promises.length) {
|
||||
await Promise.all(promises)
|
||||
}
|
||||
|
||||
return tree
|
||||
await Promise.all(nodes.map(({ href, child }) => getNewTitleSetter(child, href, context)))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ for (const page of pages) {
|
|||
// Sort by score desc so the translators know what to focus on first
|
||||
// Issues with more information should be higher
|
||||
issues = issues
|
||||
.filter((issue) => !issue.message?.includes('early-access'))
|
||||
.filter((issue) => !issue.path?.includes('early-access'))
|
||||
.sort((a, b) => b.score - a.score || JSON.stringify(b).length - JSON.stringify(a).length)
|
||||
|
||||
// Begin an output report
|
||||
|
|
Загрузка…
Ссылка в новой задаче