summaryrefslogtreecommitdiff
path: root/docs/public/nav.js
diff options
context:
space:
mode:
authorGravatar Fred K. Schott <fkschott@gmail.com> 2021-07-29 13:31:41 -0700
committerGravatar GitHub <noreply@github.com> 2021-07-29 13:31:41 -0700
commit6eeafac715aaa077f07dd12d0609301a807a0705 (patch)
tree0e163a45864794fbe2e926a0a85a189bb500f837 /docs/public/nav.js
parent908139642a7863ce38e567f791aee1972ab6ec1f (diff)
downloadastro-6eeafac715aaa077f07dd12d0609301a807a0705.tar.gz
astro-6eeafac715aaa077f07dd12d0609301a807a0705.tar.zst
astro-6eeafac715aaa077f07dd12d0609301a807a0705.zip
Add algolia-powered search bar to docs site (#917)
* add search bar * replace cmd+k with slash hotkey * update api key * add localhost support for search
Diffstat (limited to 'docs/public/nav.js')
-rw-r--r--docs/public/nav.js37
1 files changed, 0 insertions, 37 deletions
diff --git a/docs/public/nav.js b/docs/public/nav.js
deleted file mode 100644
index d6c2bcda3..000000000
--- a/docs/public/nav.js
+++ /dev/null
@@ -1,37 +0,0 @@
-const nav = document.querySelector('body > header');
-
-if (!window.matchMedia('(prefers-reduced-motion)').matches) {
- window.addEventListener('scroll', onScroll, { passive: true });
-}
-
-let prev = -1;
-let prevDir = 0;
-let threshold = 32;
-
-function onScroll() {
- const curr = window.scrollY;
- const dir = curr > prev ? 1 : -1;
-
- if (curr < threshold) {
- show();
- document.documentElement.classList.add('initial');
- } else if (dir !== prevDir) {
- if (dir === 1) {
- hide();
- } else {
- show();
- }
- }
-
- prev = curr;
-}
-
-const hide = () => {
- nav.classList.add('hidden');
- document.documentElement.classList.add('scrolled');
- document.documentElement.classList.remove('initial');
-};
-const show = () => {
- nav.classList.remove('hidden');
- document.documentElement.classList.remove('scrolled');
-};