summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Swithinbank2023-12-06 19:26:05 +0100
committerGitHub2023-12-06 19:26:05 +0100
commitd8fc9e15bd2ae4c945b5a3856a6ce3b5629e8b29 (patch)
tree3f5ea320e06c9f3bc21c653496dbe758a08192cd
parent02a808e4a0b9ac2383576e3495f6a766b663d773 (diff)
downloadIT.starlight-d8fc9e15bd2ae4c945b5a3856a6ce3b5629e8b29.tar.gz
IT.starlight-d8fc9e15bd2ae4c945b5a3856a6ce3b5629e8b29.tar.bz2
IT.starlight-d8fc9e15bd2ae4c945b5a3856a6ce3b5629e8b29.zip
Prefetch links on hover by default (#1242)
Co-authored-by: Paul Valladares <85648028+dreyfus92@users.noreply.github.com>
-rw-r--r--.changeset/sour-guests-tease.md24
-rw-r--r--package.json2
-rw-r--r--packages/starlight/index.ts2
3 files changed, 27 insertions, 1 deletions
diff --git a/.changeset/sour-guests-tease.md b/.changeset/sour-guests-tease.md
new file mode 100644
index 00000000..3fb73a89
--- /dev/null
+++ b/.changeset/sour-guests-tease.md
@@ -0,0 +1,24 @@
+---
+'@astrojs/starlight': minor
+---
+
+Enables link prefetching on hover by default
+
+Astro v4’s [prefetch](https://docs.astro.build/en/guides/prefetch) support is now enabled by default. If `prefetch` is not set in `astro.config.mjs`, Starlight will use `prefetch: { prefetchAll: true, defaultStrategy: 'hover' }` by default.
+
+If you want to preserve previous behaviour, disable link prefetching in `astro.config.mjs`:
+
+```js
+import { defineConfig } from 'astro/config';
+import starlight from '@astrojs/starlight';
+
+export default defineConfig({
+ // Disable link prefetching:
+ prefetch: false,
+
+ integrations: [
+ starlight({
+ // ...
+ }),
+ ],
+});
diff --git a/package.json b/package.json
index 3ffa2345..18de4e46 100644
--- a/package.json
+++ b/package.json
@@ -29,7 +29,7 @@
{
"name": "/_astro/*.js",
"path": "examples/basics/dist/_astro/*.js",
- "limit": "21 kB"
+ "limit": "22 kB"
},
{
"name": "/_astro/*.css",
diff --git a/packages/starlight/index.ts b/packages/starlight/index.ts
index 5aa4cd50..3b3ba76b 100644
--- a/packages/starlight/index.ts
+++ b/packages/starlight/index.ts
@@ -76,6 +76,8 @@ export default function StarlightIntegration({
config.markdown.shikiConfig.theme !== 'github-dark' ? {} : { theme: 'css-variables' },
},
scopedStyleStrategy: 'where',
+ // If not already configured, default to prefetching all links on hover.
+ prefetch: config.prefetch ?? { prefetchAll: true },
});
},