2022-03-18 17:35:45 -05:00
|
|
|
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.
|
2022-04-02 15:15:41 -05:00
|
|
|
injectScript(
|
|
|
|
'page',
|
|
|
|
`import {Turbolinks} from "@astrojs/turbolinks/client.js"; Turbolinks.start();`
|
|
|
|
);
|
2022-03-18 17:35:45 -05:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|