Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefetch links on hover by default #1242

Merged
merged 4 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .changeset/sour-guests-tease.md
Original file line number Diff line number Diff line change
@@ -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({
// ...
}),
],
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
{
"name": "/_astro/*.js",
"path": "examples/basics/dist/_astro/*.js",
"limit": "21 kB"
"limit": "22 kB"
},
{
"name": "/_astro/*.css",
Expand Down
2 changes: 2 additions & 0 deletions packages/starlight/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
});
},

Expand Down
Loading