diff --git a/client/src/app/preview/[slug]/page.tsx b/client/src/app/preview/[slug]/page.tsx index 2148b5ff74..6222ca6c3f 100644 --- a/client/src/app/preview/[slug]/page.tsx +++ b/client/src/app/preview/[slug]/page.tsx @@ -1,6 +1,6 @@ import { render } from '@react-email/render'; import { promises as fs } from 'fs'; -import { join as pathJoin, dirname } from 'path'; +import { dirname, join as pathJoin } from 'path'; import { CONTENT_DIR, getEmails } from '../../../utils/get-emails'; import Preview from './preview'; @@ -26,20 +26,20 @@ export default async function Page({ params }) { const Email = (await import(`../../../../emails/${params.slug}`)).default; const markup = render(, { pretty: true }); const plainText = render(, { plainText: true }); - const basePath = pathJoin(process.cwd(), CONTENT_DIR) + const basePath = pathJoin(process.cwd(), CONTENT_DIR); const path = pathJoin(basePath, template[0]); // the file is actually just re-exporting the default export of the original file. We need to resolve this first const exportTemplateFile: string = await fs.readFile(path, { encoding: 'utf-8', }); - const importPath = exportTemplateFile.match(/import Mail from '(.+)';/)![1] - const originalFilePath = pathJoin(dirname(path), importPath) - + const importPath = exportTemplateFile.match(/import Mail from '(.+)';/)![1]; + const originalFilePath = pathJoin(dirname(path), importPath); + const reactMarkup: string = await fs.readFile(originalFilePath, { encoding: 'utf-8', }); - + return (