diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..6c7f640 --- /dev/null +++ b/.babelrc @@ -0,0 +1,5 @@ +{ + "plugins": [ + "@babel/plugin-proposal-optional-chaining" + ] +} diff --git a/package.json b/package.json index ff710d7..0c6b35f 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "vite": "^4.1.3" }, "devDependencies": { + "@babel/plugin-proposal-optional-chaining": "^7.21.0", "@types/node": "^18.14.1", "@vuepress/core": "^2.0.0-beta.60", "@vuepress/utils": "^2.0.0-beta.60", diff --git a/src/node/plugins/replacer.ts b/src/node/plugins/replacer.ts index 89bbdae..4e7670d 100644 --- a/src/node/plugins/replacer.ts +++ b/src/node/plugins/replacer.ts @@ -70,7 +70,7 @@ export class Replacer link = link.replace('$' + i, match[i]) - value = replaces !== undefined && replaces[i] !== undefined + value = !! replaces?.[i] ? value.replace('$' + i, replaces[i](match[i])) : value.replace('$' + i, match[i]) }