mirror of
https://github.com/withastro/astro.git
synced 2024-12-23 21:53:55 -05:00
19 lines
540 B
TypeScript
19 lines
540 B
TypeScript
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
|
|
)});`
|
|
);
|
|
},
|
|
},
|
|
};
|
|
}
|