mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-23 12:31:07 +01:00
add Try new Docs button in the current docs
Signed-off-by: Artem Navoiev <tenmozes@gmail.com>
This commit is contained in:
parent
da887b49e7
commit
324ecbeed6
@ -10,19 +10,36 @@ window.addEventListener("load", function () {
|
||||
href = hash
|
||||
}
|
||||
const sidebar = document.querySelector('.sidebar .toctree');
|
||||
const selector = function(href) {return `a[href="${href}"]`};
|
||||
const selector = function (href) {
|
||||
return `a[href="${href}"]`
|
||||
};
|
||||
let element = sidebar.querySelector(selector(href));
|
||||
if (!element) {
|
||||
href = window.location.pathname;
|
||||
element = document.querySelector(selector(href));
|
||||
}
|
||||
if (element) {
|
||||
element.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" });
|
||||
element.scrollIntoView({behavior: "smooth", block: "center", inline: "nearest"});
|
||||
}
|
||||
addNewDocsButton()
|
||||
});
|
||||
|
||||
function addNewDocsButton() {
|
||||
let navigationBox = document.querySelector(".navigation-top");
|
||||
if (navigationBox) {
|
||||
let newDocsButton = document.createElement('a');
|
||||
newDocsButton.appendChild(document.createTextNode("Try New Docs"));
|
||||
newDocsButton.className = "btn";
|
||||
newDocsButton.title = "Try New Docs";
|
||||
newDocsButton.href = "https://new.docs.victoriametrics.com";
|
||||
let lastA = document.querySelector(".navigation-top > a");
|
||||
if (lastA) {
|
||||
lastA.parentNode.insertBefore(newDocsButton, lastA);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$(document).on("click", '.shift li.toc a', function(e) {
|
||||
$(document).on("click", '.shift li.toc a', function (e) {
|
||||
let segments = this.href.split('#');
|
||||
if (segments.length < 2) {
|
||||
/* ignore links without anchor */
|
||||
@ -32,8 +49,8 @@ $(document).on("click", '.shift li.toc a', function(e) {
|
||||
e.preventDefault();
|
||||
$("#toggle").click();
|
||||
setTimeout(function () {
|
||||
location.hash = segments.pop();
|
||||
},1)
|
||||
location.hash = segments.pop();
|
||||
}, 1)
|
||||
});
|
||||
|
||||
/* Clipboard-copy snippet from https://github.com/marcoaugustoandrade/jekyll-clipboardjs/blob/master/copy.js */
|
||||
|
@ -49,3 +49,16 @@
|
||||
.markdown-body h4 {
|
||||
font-family: 'Lato', sans-serif !important;
|
||||
}
|
||||
|
||||
// try new page button
|
||||
.navigation-top {
|
||||
min-height: 32px;
|
||||
}
|
||||
|
||||
.navigation-top > a:last-child{
|
||||
padding-left: 5px
|
||||
}
|
||||
|
||||
.navigation-top > .btn {
|
||||
margin-left: auto
|
||||
}
|
Loading…
Reference in New Issue
Block a user