blob: cb1c73a0bac0aaf2e8f73ac239ba39a31f08db04 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
import type { AstroIntegration } from 'astro';
import type { PrefetchOptions } from './client.js';
export default function (options: PrefetchOptions = {}): AstroIntegration {
return {
name: '@astrojs/prefetch',
hooks: {
'astro:config:setup': ({ updateConfig, addRenderer, injectScript }) => {
// Inject the necessary polyfills on every page (inlined for speed).
injectScript(
'page',
`import prefetch from "@astrojs/prefetch/client.js"; prefetch(${JSON.stringify(
options
)});`
);
},
},
};
}
|