diff --git a/docs/_includes/extra/script.js b/docs/_includes/extra/script.js index f5d1f92bf..08c736cd4 100644 --- a/docs/_includes/extra/script.js +++ b/docs/_includes/extra/script.js @@ -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 */ diff --git a/docs/_includes/extra/styles.scss b/docs/_includes/extra/styles.scss index e42980ed1..7344cb1b2 100644 --- a/docs/_includes/extra/styles.scss +++ b/docs/_includes/extra/styles.scss @@ -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 +} \ No newline at end of file