Skip to content

Commit

Permalink
Prefetch links on hover by default (#1242)
Browse files Browse the repository at this point in the history
Co-authored-by: Paul Valladares <85648028+dreyfus92@users.noreply.github.com>
  • Loading branch information
delucis and dreyfus92 committed Dec 6, 2023
1 parent 02a808e commit d8fc9e1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
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鈥檚 [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

0 comments on commit d8fc9e1

Please sign in to comment.