hexo-reslink
Version:
Automatically create resource links
16 lines • 614 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.REG = /npm:((?:@?[a-z\d][a-z\d_-]*[a-z\d]\/)?[a-z\d][a-z\d._-]*[a-z\d])/;
exports.process = (text) => {
if (!exports.REG.test(text)) {
return text;
}
text = text.replace(new RegExp(exports.REG, "g"), (words) => {
const { 1: packageName } = words.match(exports.REG);
const url = `https://www.npmjs.com/package/${packageName}`;
const title = `"Node Library: ${packageName}"`;
return `[${packageName}](${url} ${title})`;
});
return text;
};
//# sourceMappingURL=npm.js.map