summaryrefslogtreecommitdiff
path: root/packages/integrations/turbolinks/src/index.ts
blob: fbf893f6801cec068efa6baf12c1f90dc51f12ac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import type { AstroIntegration } from 'astro';

export default function createPlugin(): AstroIntegration {
	return {
		name: '@astrojs/turbolinks',
		hooks: {
			'astro:config:setup': ({ injectScript }) => {
				// This gets injected into the user's page, so we need to re-export Turbolinks
				// from our own package so that package managers like pnpm don't get mad and
				// can follow the import correctly.
				injectScript(
					'page',
					`import {Turbolinks} from "@astrojs/turbolinks/client.js"; Turbolinks.start();`
				);
			},
		},
	};
}