feat: implement no-client-JavaScript support for back-to-top and search (WIP)
This commit is contained in:
parent
5c3eba62b1
commit
a7fea79d98
4 changed files with 29 additions and 6 deletions
|
@ -1,7 +1,8 @@
|
|||
---
|
||||
|
||||
import {siteConfig} from "../config";
|
||||
const noscript = siteConfig.noClientJavaScript
|
||||
---
|
||||
<button id="toTopBtn" title="Go to top">Top</button>
|
||||
{noscript ? <a href="#top"><button id="toTopBtn" style="display: block" title="Go to top">Top</button></a> : <button id="toTopBtn" title="Go to top">Top</button>
|
||||
<script>
|
||||
// Get the button
|
||||
let toTopButton = document.getElementById("toTopBtn");
|
||||
|
@ -31,4 +32,4 @@
|
|||
document.documentElement.scrollTop = 0;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</script>}
|
|
@ -1,5 +1,17 @@
|
|||
---
|
||||
import {siteConfig} from "../config";
|
||||
const noscript = siteConfig.noClientJavaScript
|
||||
---
|
||||
{noscript ?
|
||||
<form class="search-container" action="https://www.google.com/search" method="GET" target="_blank">
|
||||
<div>
|
||||
<label for="search-input"><span class="command">search</span></label>
|
||||
<input name="q" type="text" id="search-input" class="search-input" autocomplete="off" placeholder="Type to search..." />
|
||||
<input type="hidden" name="as_sitesearch" value={Astro.url.host} />
|
||||
</div>
|
||||
<input type="submit" style="display: none" />
|
||||
</form>
|
||||
:
|
||||
<div class="search-container">
|
||||
<div class="command-prompt">
|
||||
<span class="command">search</span>
|
||||
|
@ -92,7 +104,7 @@
|
|||
document.getElementById('search-results').innerHTML = '<p>Loading search index...</p>';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</script>}
|
||||
|
||||
<style>
|
||||
.search-container {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue