|
@@ -41,6 +41,13 @@ const linkComponents = async (cwd: string) => { |
|
|
// noop |
|
|
// noop |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
await rm(resolve(destCwd, 'pages'), { recursive: true }); |
|
|
|
|
|
await cp(resolve(defaultCwd, 'pages'), resolve(destCwd, 'pages'), { recursive: true }); |
|
|
|
|
|
} catch { |
|
|
|
|
|
// noop |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
await Promise.all(componentsList.map(async (componentPath) => { |
|
|
await Promise.all(componentsList.map(async (componentPath) => { |
|
|
const destPath = resolve(destCwd, componentPath); |
|
|
const destPath = resolve(destCwd, componentPath); |
|
|
let baseCwd = projectCwd; |
|
|
let baseCwd = projectCwd; |
|
@@ -72,8 +79,12 @@ const linkComponents = async (cwd: string) => { |
|
|
const packageDir = await useBasePath(pkg.basePath); |
|
|
const packageDir = await useBasePath(pkg.basePath); |
|
|
const packageLinkDir = await useInternalPath('.amanuensis', 'next', 'node_modules', pkg.name); |
|
|
const packageLinkDir = await useInternalPath('.amanuensis', 'next', 'node_modules', pkg.name); |
|
|
await mkdirp(dirname(packageLinkDir)); |
|
|
await mkdirp(dirname(packageLinkDir)); |
|
|
console.log(packageDir, packageLinkDir); |
|
|
|
|
|
await symlink(packageDir, packageLinkDir); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
await symlink(packageDir, packageLinkDir); |
|
|
|
|
|
} catch { |
|
|
|
|
|
// noop |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
await mkdirp(resolve(destCwd, 'content', pkg.basePath)); |
|
|
await mkdirp(resolve(destCwd, 'content', pkg.basePath)); |
|
|
await mkdirp(resolve(destCwd, 'pages', pkg.basePath)); |
|
|
await mkdirp(resolve(destCwd, 'pages', pkg.basePath)); |
|
@@ -84,22 +95,30 @@ const linkComponents = async (cwd: string) => { |
|
|
await cp(srcPath, destPath); |
|
|
await cp(srcPath, destPath); |
|
|
|
|
|
|
|
|
const pageDestPath = resolve(destCwd, 'pages', pkg.basePath, `${basename(m.name, extname(m.name))}.tsx`); |
|
|
const pageDestPath = resolve(destCwd, 'pages', pkg.basePath, `${basename(m.name, extname(m.name))}.tsx`); |
|
|
|
|
|
const preambleImport = `@/${join('content', pkg.basePath, m.name)}`; |
|
|
|
|
|
|
|
|
await writeFile( |
|
|
await writeFile( |
|
|
pageDestPath, |
|
|
pageDestPath, |
|
|
`import {NextPage} from 'next'; |
|
|
`import {NextPage} from 'next'; |
|
|
import {Wrapper} from '@/components/Wrapper'; |
|
|
import {Wrapper} from '@/components/Wrapper'; |
|
|
import Content from '@/${join('content', pkg.basePath, m.name)}'; |
|
|
|
|
|
|
|
|
import {ComponentContext} from '@/contexts/Component'; |
|
|
|
|
|
import {PreambleContext} from '@/contexts/Preamble'; |
|
|
|
|
|
import Preamble from '${preambleImport}'; |
|
|
|
|
|
import {PageLayout} from '@/components/PageLayout'; |
|
|
|
|
|
|
|
|
const IndexPage: NextPage = () => { |
|
|
const IndexPage: NextPage = () => { |
|
|
return ( |
|
|
return ( |
|
|
<Wrapper> |
|
|
|
|
|
<Content /> |
|
|
|
|
|
</Wrapper> |
|
|
|
|
|
|
|
|
<PreambleContext.Provider value={Preamble}> |
|
|
|
|
|
<Wrapper> |
|
|
|
|
|
<PageLayout /> |
|
|
|
|
|
</Wrapper> |
|
|
|
|
|
</PreambleContext.Provider> |
|
|
); |
|
|
); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
export default IndexPage; |
|
|
export default IndexPage; |
|
|
`, |
|
|
`, |
|
|
|
|
|
// todo fetch components for display to props and preamble |
|
|
// todo fix problem when building with import aliases |
|
|
// todo fix problem when building with import aliases |
|
|
// todo find a way to build with tailwind |
|
|
// todo find a way to build with tailwind |
|
|
// todo link components to next project (done) |
|
|
// todo link components to next project (done) |
|
|