Skip to content

Commit

Permalink
fix(client): Lint (resend#660)
Browse files Browse the repository at this point in the history
  • Loading branch information
bukinoshita authored Apr 25, 2023
1 parent 1870285 commit 09795a2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions client/src/app/preview/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -26,20 +26,20 @@ export default async function Page({ params }) {
const Email = (await import(`../../../../emails/${params.slug}`)).default;
const markup = render(<Email />, { pretty: true });
const plainText = render(<Email />, { 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 (
<Preview
navItems={emails}
Expand Down

0 comments on commit 09795a2

Please sign in to comment.