|
123 | 123 | maxLevel: 2,
|
124 | 124 | mergeNavbar: true,
|
125 | 125 | auto2top: true,
|
| 126 | + routerMode: 'history', |
126 | 127 | plugins: [
|
127 | 128 | EditOnGithubPlugin.create(config.editOnGithub.docBase, null, config.editOnGithub.title),
|
128 | 129 | ],
|
129 | 130 | };
|
| 131 | + |
| 132 | + window.$docsify.plugins.push((hook, vm) => { |
| 133 | + |
| 134 | + hook.doneEach(() => { |
| 135 | + // fixing broken images & broken links |
| 136 | + var images = document.querySelectorAll('img[src^="_media"]'); |
| 137 | + for (let image of images) { |
| 138 | + image.src = image.src.replace(/.*\/(?=_)/g, '/'); |
| 139 | + }; |
| 140 | + }); |
| 141 | + |
| 142 | + hook.ready(() => { |
| 143 | + // In future update of docsify change the crossOriginLinks to vm.config.crossOriginLinks |
| 144 | + var crossOriginLinks = [ |
| 145 | + "https://ml5js.org", |
| 146 | + "https://ml5js.github.io/ml5-library/docs/#/reference/index", |
| 147 | + "https://ml5js.org/community/", |
| 148 | + "https://ml5js.org/about/", |
| 149 | + "https://github.com/ml5js/ml5-library", |
| 150 | + "https://ml5js.github.io/ml5-library/docs/#/", |
| 151 | + ] |
| 152 | + // Remove this code after update. |
| 153 | + for (let link of crossOriginLinks) { |
| 154 | + var el = document.querySelector(`a[href="${link}"]`); |
| 155 | + if (el !== null) { |
| 156 | + el.addEventListener('click', (el) => { |
| 157 | + window.open(link, '_self'); |
| 158 | + }); |
| 159 | + } |
| 160 | + } |
| 161 | + // handling redirects |
| 162 | + vm.route = vm.router.parse(); |
| 163 | + document.body.setAttribute('data-page', vm.route.file); |
| 164 | + vm._updateRender(); |
| 165 | + vm.$fetch(() => { }, vm.$resetEvents.bind(vm, 'navigate')); |
| 166 | + }); |
| 167 | + |
| 168 | + }); |
130 | 169 | </script>
|
131 | 170 | <script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
|
132 | 171 | <!-- Plugins -->
|
|
0 commit comments