Align adapter setup (#6874)

This commit is contained in:
Nathaniel Blackburn 2023-04-19 08:36:46 +01:00 committed by GitHub
parent dec072f57f
commit 43230b2cac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View file

@ -0,0 +1,5 @@
---
'@astrojs/vercel': patch
---
Refactor static adapter to use updateConfig method

View file

@ -19,12 +19,17 @@ export default function vercelStatic({ analytics }: VercelStaticConfig = {}): As
return {
name: '@astrojs/vercel',
hooks: {
'astro:config:setup': ({ command, config, injectScript }) => {
'astro:config:setup': ({ command, config, updateConfig, injectScript }) => {
if (command === 'build' && analytics) {
injectScript('page', 'import "@astrojs/vercel/analytics"');
}
config.outDir = new URL('./static/', getVercelOutput(config.root));
config.build.format = 'directory';
const outDir = new URL('./static/', getVercelOutput(config.root));
updateConfig({
outDir,
build: {
format: 'directory',
},
});
},
'astro:config:done': ({ setAdapter, config }) => {
setAdapter(getAdapter());