import * as fs from 'fs' import * as path from 'path' import { LoadedUnbodyConfig } from '../types' const themeConfig = ({ originalPath, config, }: { originalPath: string config: LoadedUnbodyConfig }) => ` import React from 'react' import defaultThemeConfig from "${originalPath}" import { Search } from "unbody-nextra-ui" const SearchComponent = () => { return ( ) } export default { ...defaultThemeConfig, search: { component: SearchComponent } } `.slice(1) export const setupThemeConfig = ({ config, originalPath, }: { originalPath: string config: LoadedUnbodyConfig }) => { if (!config.setupComponents) return const filename = path.join(config.dir, 'theme.config.tsx') fs.writeFileSync(filename, themeConfig({ originalPath, config })) return filename }