0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-13 22:11:20 -05:00
astro/packages/integrations/prefetch/src/index.ts
Robin Lindner 6ad91bd80d
Improve prefetch conditions (#5244)
* Improve prefetch

* Add changeset
2022-11-01 08:42:30 -04:00

19 lines
513 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': ({ injectScript }) => {
// Inject the necessary polyfills on every page (inlined for speed).
injectScript(
'page',
`import prefetch from "@astrojs/prefetch/client.js"; prefetch(${JSON.stringify(
options
)});`
);
},
},
};
}