Skip to content

Commit f5ba5d7

Browse files
Fixed Issue #647
1 parent 6842546 commit f5ba5d7

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

docs/_redirects

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* /index.html 200

docs/index.html

+39
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,49 @@
123123
maxLevel: 2,
124124
mergeNavbar: true,
125125
auto2top: true,
126+
routerMode: 'history',
126127
plugins: [
127128
EditOnGithubPlugin.create(config.editOnGithub.docBase, null, config.editOnGithub.title),
128129
],
129130
};
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+
});
130169
</script>
131170
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
132171
<!-- Plugins -->

0 commit comments

Comments
 (0)