mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-11 15:34:56 +00:00
add Try new Docs button in the current docs
Signed-off-by: Artem Navoiev <tenmozes@gmail.com>
This commit is contained in:
parent
ae9b4c94bc
commit
23d09684a6
2 changed files with 35 additions and 5 deletions
|
@ -10,19 +10,36 @@ window.addEventListener("load", function () {
|
||||||
href = hash
|
href = hash
|
||||||
}
|
}
|
||||||
const sidebar = document.querySelector('.sidebar .toctree');
|
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));
|
let element = sidebar.querySelector(selector(href));
|
||||||
if (!element) {
|
if (!element) {
|
||||||
href = window.location.pathname;
|
href = window.location.pathname;
|
||||||
element = document.querySelector(selector(href));
|
element = document.querySelector(selector(href));
|
||||||
}
|
}
|
||||||
if (element) {
|
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('#');
|
let segments = this.href.split('#');
|
||||||
if (segments.length < 2) {
|
if (segments.length < 2) {
|
||||||
/* ignore links without anchor */
|
/* ignore links without anchor */
|
||||||
|
@ -32,8 +49,8 @@ $(document).on("click", '.shift li.toc a', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$("#toggle").click();
|
$("#toggle").click();
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
location.hash = segments.pop();
|
location.hash = segments.pop();
|
||||||
},1)
|
}, 1)
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Clipboard-copy snippet from https://github.com/marcoaugustoandrade/jekyll-clipboardjs/blob/master/copy.js */
|
/* Clipboard-copy snippet from https://github.com/marcoaugustoandrade/jekyll-clipboardjs/blob/master/copy.js */
|
||||||
|
|
|
@ -49,3 +49,16 @@
|
||||||
.markdown-body h4 {
|
.markdown-body h4 {
|
||||||
font-family: 'Lato', sans-serif !important;
|
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 a new issue