| 49 | }; |
| 50 | |
| 51 | function configureMarkdownIt() { |
| 52 | return require("markdown-it")({ |
| 53 | html: true, |
| 54 | linkify: true, |
| 55 | replaceLink: function rewriteRelativeLinks (link, env) { |
| 56 | // TODO(davideast): Create readable expressions or matches |
| 57 | // for this if statement tree. |
| 58 | if (link.indexOf('./') !== -1) { |
| 59 | link = link.replace('./', '/reference/'); |
| 60 | if (link === '/reference/index') { |
| 61 | link = '/reference'; |
| 62 | } |
| 63 | if (link === '/reference/firestore') { |
| 64 | link = '/reference/firestore_'; |
| 65 | } |
| 66 | } |
| 67 | return link; |
| 68 | } |
| 69 | }).use(require('markdown-it-attrs')) |
| 70 | // https://github.com/markdown-it/markdown-it-container/issues/23 |
| 71 | .use(require('markdown-it-container'), 'dynamic', { |
| 72 | validate: function () { return true; }, |
| 73 | render: function (tokens, idx) { |
| 74 | const token = tokens[idx]; |
| 75 | if (token.nesting === 1) { |
| 76 | return '<div class="' + token.info.trim() + '">'; |
| 77 | } else { |
| 78 | return '</div>'; |
| 79 | } |
| 80 | }, |
| 81 | }) |
| 82 | .use(require('markdown-it-replace-link')) |
| 83 | .use(prism); |
| 84 | } |
| 85 | |
| 86 | function registerShortcodes(eleventyConfig) { |
| 87 | const { shortcodes } = require('./src/shortcodes'); |