⚙️ Replace Twitter links with Mastodon ones

This commit is contained in:
Dennis Reimann
2021-01-12 16:02:05 +01:00
parent 6a2937d1bf
commit dc1e0b86f2
4 changed files with 15 additions and 6 deletions

22
helpers.js Normal file
View File

@@ -0,0 +1,22 @@
// configure markdown-it
const transformer = require('jstransformer')
const { _tr: mdTransformer } = transformer(require('jstransformer-markdown-it'))
const config = {
typographer: true,
}
// monkey-patch render function to pass custom options
const { render: renderMd } = mdTransformer
mdTransformer.render = str => renderMd(str, config)
// replacements
const replacements = str => {
return str.replace(/"https:\/\/twitter\.com\/_d11n_\/?"/, '"https://bitcoinhackers.org/@d11n"')
}
module.exports = {
markdown: mdTransformer.render,
replacements
}