feat: implement no-client-JavaScript support for back-to-top and search (WIP)

This commit is contained in:
grassblock 2025-05-22 21:43:35 +08:00
parent 5c3eba62b1
commit a7fea79d98
4 changed files with 29 additions and 6 deletions

View file

@ -15,6 +15,8 @@ interface Props {
ogImage?: string;
}
const noscript = siteConfig.noClientJavaScript
const defaultTitle = siteConfig.title
const formattedRootPath = defaultTitle.toLowerCase().replace(/\s+/g, '-');
const relativePath = Astro.url.pathname
@ -41,6 +43,7 @@ const { title = pageTitle, description = siteConfig.description, ogImage = "" }
</head>
<body>
<main>
{noscript && <div id="top" style="visibility: hidden">Back To Top</div>}
<div class="container">
<div class="terminal-path">
{path}
@ -70,7 +73,7 @@ const { title = pageTitle, description = siteConfig.description, ogImage = "" }
<p>Powered by <a href="https://git.gb0.dev/gb/mercury" target="_blank"><Logo width={16} height={16} /> mercury</a></p>
</div>
</footer>
{ siteConfig.neko.enabled &&
{ !noscript || siteConfig.neko.enabled &&
<>
<script is:inline define:vars={{ nekoType }}>
window.NekoType = nekoType;