prefetch sites on hovering their links in navbar

This commit is contained in:
2024-10-24 00:39:17 +02:00
parent 998d56e2e7
commit 8afd44ff49
3 changed files with 9 additions and 7 deletions
+4 -2
View File
@@ -1,5 +1,4 @@
import { defineConfig } from 'astro/config' import { defineConfig } from 'astro/config'
import svelte from '@astrojs/svelte'
import mdx from '@astrojs/mdx' import mdx from '@astrojs/mdx'
import remarkGfm from 'remark-gfm' import remarkGfm from 'remark-gfm'
import remarkSmartypants from 'remark-smartypants' import remarkSmartypants from 'remark-smartypants'
@@ -8,7 +7,10 @@ import rehypeExternalLinks from 'rehype-external-links'
// https://astro.build/config // https://astro.build/config
export default defineConfig({ export default defineConfig({
site: 'https://youhavetrouble.me', site: 'https://youhavetrouble.me',
integrations: [mdx(), svelte()], prefetch: {
defaultStrategy: 'hover',
},
integrations: [mdx()],
markdown: { markdown: {
shikiConfig: { shikiConfig: {
theme: 'nord', theme: 'nord',
+4 -4
View File
@@ -75,9 +75,9 @@ const { current = '' } = Astro.props;
<nav> <nav>
<div class="nav-buttons"> <div class="nav-buttons">
<a class={current === "" ? "selected" : ""} href='/'>home</a> <a data-astro-prefetch class={current === "" ? "selected" : ""} href='/'>home</a>
<a class={current === "about" ? "selected" : ""} href='/about'>about</a> <a data-astro-prefetch class={current === "about" ? "selected" : ""} href='/about'>about</a>
<a class={current === "projects" ? "selected" : ""} href='/projects'>projects</a> <a data-astro-prefetch class={current === "projects" ? "selected" : ""} href='/projects'>projects</a>
<a class={current === "blog" ? "selected" : ""} href='/blog'>blog</a> <a data-astro-prefetch class={current === "blog" ? "selected" : ""} href='/blog'>blog</a>
</div> </div>
</nav> </nav>
+1 -1
View File
@@ -21,7 +21,7 @@ const allPosts= posts.sort((a, b) => new Date(b.data.publishDate).valueOf() - ne
{ index !== 0 && <hr /> } { index !== 0 && <hr /> }
<div class="post-item"> <div class="post-item">
<h2> <h2>
<a href={href}>{post.data.title}</a> <a data-astro-prefetch href={href}>{post.data.title}</a>
</h2> </h2>
<div class="tags"> <div class="tags">
{post.data.tags.map(item => ( {post.data.tags.map(item => (