2022-03-21 12:33:31 -05:00
|
|
|
import type { Integration } from './frameworks';
|
|
|
|
|
|
|
|
export const createConfig = ({ integrations }: { integrations: Integration[] }) => {
|
2022-03-18 17:35:45 -05:00
|
|
|
if (integrations.length === 0) {
|
|
|
|
return `import { defineConfig } from 'astro/config';
|
|
|
|
// https://astro.build/config
|
|
|
|
export default defineConfig({});
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
|
2022-03-21 12:33:31 -05:00
|
|
|
const rendererImports = integrations.map((r) => ` import ${r.id} from '${r.packageName}';`);
|
|
|
|
const rendererIntegrations = integrations.map((r) => ` ${r.id}(),`);
|
2021-07-07 15:10:09 -05:00
|
|
|
return [
|
2022-03-18 17:35:45 -05:00
|
|
|
`import { defineConfig } from 'astro/config';`,
|
|
|
|
...rendererImports,
|
|
|
|
`// https://astro.build/config`,
|
|
|
|
`export default defineConfig({`,
|
|
|
|
` integrations: [`,
|
|
|
|
...rendererIntegrations,
|
|
|
|
` ]`,
|
|
|
|
`});`,
|
2021-07-07 15:10:09 -05:00
|
|
|
].join('\n');
|
|
|
|
};
|