summaryrefslogtreecommitdiff
path: root/packages/create-astro/src/config.ts
blob: 4060d368c5e8bea6325af99f93e1ef8e21ea1b17 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import type { Integration } from './frameworks';

export const createConfig = ({ integrations }: { integrations: Integration[] }) => {
	if (integrations.length === 0) {
		return `import { defineConfig } from 'astro/config';
// https://astro.build/config
export default defineConfig({});
`;
	}

	const rendererImports = integrations.map((r) => `  import ${r.id} from '${r.packageName}';`);
	const rendererIntegrations = integrations.map((r) => `    ${r.id}(),`);
	return [
		`import { defineConfig } from 'astro/config';`,
		...rendererImports,
		`// https://astro.build/config`,
		`export default defineConfig({`,
		`  integrations: [`,
		...rendererIntegrations,
		`  ]`,
		`});`,
	].join('\n');
};