-
Notifications
You must be signed in to change notification settings - Fork 143
/
Copy pathdocs.js
33 lines (27 loc) · 999 Bytes
/
docs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* global $ */
(function () {
var anchorHeadingsSelector = 'h2[id], h3[id], h4[id], h5[id], h6[id]';
var content = $('.content');
if (content) {
if (window.location.hash) {
window.location.hash = window.location.hash.toLowerCase();
}
content.addEventListener('click', function (e) {
var el = e.target;
if (el.matches && el.matches(anchorHeadingsSelector)) {
window.location.hash = '#' + el.id;
ga('send', 'pageview', {
page: location.pathname + location.search + location.hash
});
}
});
// NOTE: Hack because variables doesn't get interpolated correctly in Markdown code blocks.
// This is for `/docs/<version>/guide/getting-started.html`
if (document.querySelector('#builds')) {
var versionEls = document.querySelectorAll('.highlight .code .string');
for (var i = 0; i < versionEls.length; ++i) {
versionEls[i].textContent = versionEls[i].textContent.replace('\{\{ version \}\}', settings.docsVersion);
}
}
}
})();