mirror of
https://github.com/qdrant/landing_page.git
synced 2026-09-29 07:58:31 +02:00
* added smooth scroll to anchores inside blog and articles * smooth scroll with pushing hash to history
226 lines
6.6 KiB
HTML
226 lines
6.6 KiB
HTML
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
|
|
<script src="{{ "js/jquery.js" | absURL }}"></script>
|
|
<script src="{{ "js/jquery.mCustomScrollbar.concat.min.js" | absURL }}"></script>
|
|
<script src="{{ "js/cookit.js" | absURL }}"></script>
|
|
<script src="{{ "js/clipboard.min.js" | absURL }}"></script>
|
|
<script src="{{ "js/anchor.min.js" | absURL }}"></script>
|
|
<script src="{{ "js/vendor.min.js" | absURL }}"></script>
|
|
{{ if or (eq .Section "documentation") (eq .Section "blog") }}
|
|
<script src="{{ "js/qdr-search.min.js" | absURL }}"></script>
|
|
{{ end }}
|
|
<script src="{{ "js/qdr-scroll.min.js" | absURL }}"></script>
|
|
<script src="{{ "js/script.js" | absURL }}"></script>
|
|
<script>
|
|
var clipboard = new ClipboardJS('.copy-btn');
|
|
|
|
clipboard.on('success', function (e) {
|
|
$('#copy-popover').popover('show')
|
|
const to = setTimeout(() => {
|
|
$('#copy-popover').popover('hide')
|
|
$('#modal').modal('show')
|
|
clearTimeout(to);
|
|
}, 3000);
|
|
e.clearSelection();
|
|
});
|
|
|
|
clipboard.on('error', function (e) {
|
|
console.error('Action:', e.action);
|
|
console.error('Trigger:', e.trigger);
|
|
});
|
|
|
|
$(function () {
|
|
$.cookit({
|
|
messageText: "{{ .Site.Params.gdpr }}",
|
|
linkText: "Learn more",
|
|
linkUrl: "/legal/privacy-policy",
|
|
buttonText: "I accept",
|
|
backgroundColor: '#1c1c1c',
|
|
messageColor: '#fff',
|
|
linkColor: '#fad04c',
|
|
buttonColor: '#fad04c'
|
|
});
|
|
});
|
|
|
|
anchors.options.placement = 'left';
|
|
anchors.add("article > :is(h1, h2, h3, h4, h5, h6)");
|
|
</script>
|
|
|
|
<script src="{{ "js/lang-switcher.js" | absURL }}"></script>
|
|
<script src="{{ "js/copy-code.js" | absURL }}"></script>
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
$('[data-toggle="popover"]').popover({
|
|
container: 'body'
|
|
});
|
|
$('.popover-dismiss').popover({
|
|
trigger: 'focus'
|
|
});
|
|
|
|
// qdrant-page-search initialization
|
|
if (/documentation/.test(window.location?.pathname)) {
|
|
window.initQdrantSearch({searchApiUrl: 'https://search.qdrant.tech/api/search', section: "documentation"});
|
|
}
|
|
|
|
if (/blog\/?$/.test(window.location?.pathname)) {
|
|
window.initQdrantSearch({searchApiUrl: 'https://search.qdrant.tech/api/search', section: "blog"});
|
|
}
|
|
});
|
|
</script>
|
|
|
|
|
|
{{ if .IsHome }}
|
|
<script>
|
|
// Check that current url contains `?token=...` parameter
|
|
// And if so, redirec to `/admin?token=...` page
|
|
|
|
// Get the current URL
|
|
const url = window.location.href;
|
|
|
|
// Use URLSearchParams to parse the query parameters
|
|
const params = new URLSearchParams(url.split('#')[1]);
|
|
|
|
// Check if the 'token' parameter is present
|
|
if (params.has('recovery_token')) {
|
|
// Get the value of the 'token' parameter
|
|
const token = params.get('recovery_token');
|
|
// Redirect to the '/admin' page with the same 'token' parameter
|
|
window.location.href = '/admin/#recovery_token=' + token;
|
|
}
|
|
|
|
// Check if the 'token' parameter is present
|
|
if (params.has('invite_token')) {
|
|
// Get the value of the 'token' parameter
|
|
const token = params.get('invite_token');
|
|
// Redirect to the '/admin' page with the same 'token' parameter
|
|
window.location.href = '/admin/#invite_token=' + token;
|
|
}
|
|
|
|
// Check if the 'token' parameter is present
|
|
if (params.has('confirmation_token')) {
|
|
// Get the value of the 'token' parameter
|
|
const token = params.get('confirmation_token');
|
|
// Redirect to the '/admin' page with the same 'token' parameter
|
|
window.location.href = '/admin/#confirmation_token=' + token;
|
|
}
|
|
</script>
|
|
{{ end }}
|
|
|
|
|
|
|
|
{{ if not .IsHome }}
|
|
|
|
<!-- MathJax support -->
|
|
<script>
|
|
MathJax = {
|
|
tex: {
|
|
inlineMath: [['$', '$'], ['\\(', '\\)']],
|
|
displayMath: [['$$','$$'], ['\\[', '\\]']],
|
|
processEscapes: true,
|
|
processEnvironments: true
|
|
},
|
|
options: {
|
|
skipHtmlTags: ['script', 'noscript', 'style', 'textarea', 'pre']
|
|
}
|
|
};
|
|
|
|
window.addEventListener('load', (event) => {
|
|
document.querySelectorAll("mjx-container").forEach(function(x){
|
|
x.parentElement.classList += 'has-jax'})
|
|
});
|
|
|
|
</script>
|
|
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
|
{{ end }}
|
|
|
|
{{ if eq .Section "documentation" }}
|
|
<script>
|
|
$(function() {
|
|
// table of contents
|
|
document.querySelectorAll('#TOC a').forEach(function(el) {
|
|
if (el.innerText) el.setAttribute('title', el.innerText)
|
|
});
|
|
|
|
// sidebar
|
|
const moveSearchButton = function() {
|
|
if ($(window).width() > 991) {
|
|
$('.qdr-search-input-btn').detach().prependTo('#sidebar > #accordion');
|
|
} else {
|
|
$('.qdr-search-input-btn').detach().prependTo('#sidebar-mobile-header');
|
|
}
|
|
}
|
|
|
|
moveSearchButton();
|
|
|
|
$('#sidebar-toggle').on('click', function () {
|
|
$('#sidebar').slideToggle();
|
|
$(this).toggleClass('active');
|
|
});
|
|
|
|
$(window).on('resize', function () {
|
|
moveSearchButton();
|
|
if ($(window).width() > 991) {
|
|
$('#sidebar').show();
|
|
}
|
|
});
|
|
})
|
|
</script>
|
|
{{ end }}
|
|
|
|
{{ if or (or (eq .Section "articles") (eq .Section "blog")) (eq .Section "documentation") }}
|
|
<script>
|
|
|
|
function scrollIntoViewWithOffset (id, offset) {
|
|
offset = offset || 0
|
|
|
|
const targetPosition = document.getElementById(id).getBoundingClientRect().top -
|
|
document.body.getBoundingClientRect().top -
|
|
offset;
|
|
|
|
window.scrollTo({
|
|
top: targetPosition,
|
|
behavior: 'smooth'
|
|
})
|
|
|
|
return new Promise(resolve => {
|
|
const scrollHandler = () => {
|
|
// resolve promise when scroll is finished
|
|
if (window.scrollY.toFixed() === targetPosition.toFixed()) {
|
|
window.removeEventListener('scroll', scrollHandler)
|
|
resolve()
|
|
}
|
|
}
|
|
window.addEventListener('scroll', scrollHandler)
|
|
})
|
|
}
|
|
|
|
(function() {
|
|
const header = document.querySelector('.main-header');
|
|
const isHeaderInViewport = header.getBoundingClientRect().top === 0;
|
|
|
|
let offsetPosition;
|
|
|
|
if (isHeaderInViewport) {
|
|
offsetPosition = document.querySelector('.main-header')?.getBoundingClientRect().height + 30;
|
|
} else {
|
|
offsetPosition = 100;
|
|
}
|
|
|
|
if (window.location.hash) {
|
|
scrollIntoViewWithOffset(window.location.hash.replace('#', ''), offsetPosition);
|
|
}
|
|
|
|
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
|
|
const target = anchor.getAttribute('href');
|
|
anchor.addEventListener('click', function (e) {
|
|
e.preventDefault();
|
|
scrollIntoViewWithOffset(target.replace('#', ''), offsetPosition)
|
|
.then(() => {
|
|
history.pushState(null, null, target);
|
|
});
|
|
});
|
|
});
|
|
|
|
})();
|
|
</script>
|
|
{{ end }}
|