Skip to content

Commit 22b517e

Browse files
author
Peter Bengtsson
authored
Make rewriteLocalLinks Markdown plugin async (github#36763)
1 parent c6eb4a7 commit 22b517e

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

lib/render-content/plugins/rewrite-local-links.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ export default function rewriteLocalLinks(context) {
4646
// There's no languageCode or version passed, so nothing to do
4747
if (!currentLanguage || !currentVersion) return
4848

49-
return async (tree) => {
50-
const promises = []
51-
49+
return async function (tree) {
50+
const nodes = []
5251
visit(tree, matcherInternalLinks, (node) => {
5352
const newHref = getNewHref(node, currentLanguage, currentVersion)
5453
if (newHref) {
@@ -57,7 +56,7 @@ export default function rewriteLocalLinks(context) {
5756
for (const child of node.children) {
5857
if (child.value) {
5958
if (AUTOTITLE.test(child.value)) {
60-
promises.push(getNewTitleSetter(child, node.properties.href, context))
59+
nodes.push({ href: node.properties.href, child })
6160
} else if (process.env.NODE_ENV !== 'production') {
6261
// Throw if the link text *almost* is AUTOTITLE
6362
if (
@@ -89,11 +88,7 @@ export default function rewriteLocalLinks(context) {
8988
})
9089
}
9190

92-
if (promises.length) {
93-
await Promise.all(promises)
94-
}
95-
96-
return tree
91+
await Promise.all(nodes.map(({ href, child }) => getNewTitleSetter(child, href, context)))
9792
}
9893
}
9994

script/i18n/create-translation-health-report.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ for (const page of pages) {
125125
// Sort by score desc so the translators know what to focus on first
126126
// Issues with more information should be higher
127127
issues = issues
128-
.filter((issue) => !issue.message?.includes('early-access'))
128+
.filter((issue) => !issue.path?.includes('early-access'))
129129
.sort((a, b) => b.score - a.score || JSON.stringify(b).length - JSON.stringify(a).length)
130130

131131
// Begin an output report

0 commit comments

Comments
 (0)