summaryrefslogtreecommitdiff
path: root/packages/integrations/prefetch
diff options
context:
space:
mode:
authorGravatar Subha Chanda <subhachanda88@gmail.com> 2023-01-27 00:33:00 +0530
committerGravatar GitHub <noreply@github.com> 2023-01-26 13:03:00 -0600
commit1c7eef308e808aa5ed4662b53e67ec8d1b814d1f (patch)
treedb310a2ce6c92ecc82bd75424f5f471ad0e72605 /packages/integrations/prefetch
parent607f0ac31a43595252bc647c01ac4b75fc774202 (diff)
downloadastro-1c7eef308e808aa5ed4662b53e67ec8d1b814d1f.tar.gz
astro-1c7eef308e808aa5ed4662b53e67ec8d1b814d1f.tar.zst
astro-1c7eef308e808aa5ed4662b53e67ec8d1b814d1f.zip
Updated according to new configuration (#5478)
* Updated according to new configuration Astro imports the `defineConfig` function from `astro/config`. The `integrations` key needs to be passed into the `defineConfig` function, but it is not shown in the README. Updated the README according to the CLI example. * update alpine * update image * update lit * update mdx * update preact * update prefetch * update react * update sitemap * update solid * update svelte * update tailwind * update turbolinks * update vue * chore: add changeset * update image * update svelte readme Co-authored-by: Nate Moore <nate@astro.build> Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
Diffstat (limited to 'packages/integrations/prefetch')
-rw-r--r--packages/integrations/prefetch/README.md21
1 files changed, 14 insertions, 7 deletions
diff --git a/packages/integrations/prefetch/README.md b/packages/integrations/prefetch/README.md
index 1d4a5ff05..ba0c2eb1a 100644
--- a/packages/integrations/prefetch/README.md
+++ b/packages/integrations/prefetch/README.md
@@ -41,13 +41,14 @@ Then, apply this integration to your `astro.config.*` file using the `integratio
__`astro.config.mjs`__
-```js
+```js ins={2} "prefetch()"
+import { defineConfig } from 'astro/config';
import prefetch from '@astrojs/prefetch';
-export default {
+export default defineConfig({
// ...
integrations: [prefetch()],
-}
+});
```
@@ -63,31 +64,37 @@ The Astro Prefetch integration handles which links on the site are prefetched an
By default the prefetch script searches the page for any links that include a `rel="prefetch"` attribute, ex: `<a rel="prefetch" />` or `<a rel="nofollow prefetch" />`. This behavior can be changed in your `astro.config.*` file to use a custom query selector when finding prefetch links.
+__`astro.config.mjs`__
+
```js
+import { defineConfig } from 'astro/config';
import prefetch from '@astrojs/prefetch';
-export default {
+export default defineConfig({
// ...
integrations: [prefetch({
// Only prefetch links with an href that begins with `/products`
selector: "a[href^='/products']"
})],
-}
+});
```
### config.throttle
By default the prefetch script will only prefetch one link at a time. This behavior can be changed in your `astro.config.*` file to increase the limit for concurrent downloads.
+__`astro.config.mjs`__
+
```js
+import { defineConfig } from 'astro/config';
import prefetch from '@astrojs/prefetch';
-export default {
+export default defineConfig({
// ...
integrations: [prefetch({
// Allow up to three links to be prefetched concurrently
throttle: 3
})],
-}
+});
```
## Troubleshooting