chore(root): Rebase canary into main (#1141)

Co-authored-by: Yangshun Tay <tay.yang.shun@gmail.com>
Co-authored-by: Vitor Capretz <capretzvitor@gmail.com>
Co-authored-by: Bastien Robert <bastienrobert@outlook.com>
Co-authored-by: Mohit Yadav <mohit@mohitya.dev>
Co-authored-by: Mark Aloo <38157066+thecodeinfluencer@users.noreply.github.com>
Co-authored-by: Marcus Stenbeck <marcus.stenbeck@gmail.com>
Co-authored-by: Jonathan Warykowski <jonathan@warykowski.io>
Co-authored-by: Zeno Rocha <zno.rocha@gmail.com>
Co-authored-by: Urs Wolfer <uwolfer@fwo.ch>
This commit is contained in:
Gabriel Miranda
2024-01-16 08:51:17 -03:00
committed by Bu Kinoshita
parent 77f612dda6
commit f21ee9d1c5
4 changed files with 131 additions and 11 deletions
+15
View File
@@ -0,0 +1,15 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
experimental: {
serverComponentsExternalPackages: [
'@react-email/components',
'@react-email/render',
'@react-email/tailwind'
],
externalDir: true // compile files that are located next to the .react-email directory
},
};
module.exports = nextConfig;
+47
View File
@@ -0,0 +1,47 @@
{
"name": "react-email-client",
"version": "0.0.15-canary.0",
"description": "The React Email preview application",
"license": "MIT",
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"format:check": "prettier --check \"**/*.{ts,tsx,md}\"",
"format": "prettier --write \"**/*.{ts,tsx,md}\""
},
"engines": {
"node": ">=18.0.0"
},
"dependencies": {
"@radix-ui/colors": "1.0.1",
"@radix-ui/react-collapsible": "1.0.3",
"@radix-ui/react-popover": "1.0.6",
"@radix-ui/react-slot": "1.0.2",
"@radix-ui/react-toggle-group": "1.0.4",
"@radix-ui/react-tooltip": "1.0.6",
"@react-email/render": "0.0.10",
"classnames": "2.3.2",
"framer-motion": "8.5.5",
"next": "14.0.3",
"prism-react-renderer": "1.3.5",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@types/node": "18.11.9",
"@types/react": "18.2.23",
"@types/react-dom": "18.2.8",
"autoprefixer": "10.4.14",
"eslint": "8.45.0",
"eslint-config-next": "13.4.10",
"eslint-config-prettier": "8.8.0",
"eslint-plugin-simple-import-sort": "10.0.0",
"eslint-plugin-unused-imports": "3.0.0",
"postcss": "8.4.26",
"prettier": "3.0.0",
"tailwindcss": "3.3.3",
"typescript": "5.1.6"
}
}
+61
View File
@@ -0,0 +1,61 @@
import { renderAsync } from '@react-email/render';
import { promises as fs } from 'fs';
import { dirname, join as pathJoin } from 'path';
import { CONTENT_DIR, getEmails } from '../../../utils/get-emails';
import Preview from './preview';
export const dynamicParams = true;
export async function generateStaticParams() {
const { emails } = await getEmails();
const paths = emails.map((email) => {
return { slug: email };
});
return paths;
}
export default async function Page({ params }) {
const { emails, filenames } = await getEmails();
const template = filenames.filter((email) => {
const [fileName] = email.split('.');
return params.slug === fileName;
});
const Email = (await import(`../../../../emails/${params.slug}`)).default;
const previewProps = Email.PreviewProps || {};
const markup = await renderAsync(<Email {...previewProps} />, {
pretty: true,
});
const plainText = await renderAsync(<Email {...previewProps} />, {
plainText: true,
});
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 reactMarkup: string = await fs.readFile(originalFilePath, {
encoding: 'utf-8',
});
return (
<Preview
navItems={emails}
slug={params.slug}
markup={markup}
reactMarkup={reactMarkup}
plainText={plainText}
/>
);
}
export async function generateMetadata({ params }) {
return { title: `${params.slug} — React Email` };
}
+8 -11
View File
@@ -2547,13 +2547,8 @@ packages:
postcss: 8.4.31
dev: true
/@types/prismjs@1.26.1:
resolution: {integrity: sha512-Q7jDsRbzcNHIQje15CS/piKhu6lMLb9jwjxSfEIi4KcFKXW23GoJMkwQiJ8VObyfx+VmUaDcJxXaWN+cTCjVog==}
dev: false
/@types/prismjs@1.26.2:
resolution: {integrity: sha512-/r7Cp7iUIk7gts26mHXD66geUC+2Fo26TZYjQK6Nr4LDfi6lmdRmMqM0oPwfiMhUwoBAOFe8GstKi2pf6hZvwA==}
dev: true
/@types/prop-types@15.7.7:
resolution: {integrity: sha512-FbtmBWCcSa2J4zL781Zf1p5YUBXQomPEcep9QZCfRfQgTxz3pJWiDFLebohZ9fFntX5ibzOkSsrJ0TEew8cAog==}
@@ -4579,6 +4574,7 @@ packages:
/eslint@8.50.0:
resolution: {integrity: sha512-FOnOGSuFuFLv/Sa+FDVRZl4GGVAAFFi8LecRsI5a1tMO5HIE8nCm4ivAlzt4dT3ol/PaaGC0rJEEXQmHJBGoOg==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
hasBin: true
dependencies:
'@eslint-community/eslint-utils': 4.4.0(eslint@8.50.0)
'@eslint-community/regexpp': 4.9.0
@@ -4944,10 +4940,11 @@ packages:
/glob@10.3.4:
resolution: {integrity: sha512-6LFElP3A+i/Q8XQKEvZjkEWEOTgAIALR9AO2rwT8bgPhDd1anmqDJDZ6lLddI4ehxxxR1S5RIqKe1uapMQfYaQ==}
engines: {node: '>=16 || 14 >=14.17'}
hasBin: true
dependencies:
foreground-child: 3.1.1
jackspeak: 2.3.6
minimatch: 9.0.1
minimatch: 9.0.3
minipass: 7.0.4
path-scurry: 1.10.1
dev: false
@@ -6027,7 +6024,6 @@ packages:
engines: {node: '>=16 || 14 >=14.17'}
dependencies:
brace-expansion: 2.0.1
dev: true
/minimist-options@4.1.0:
resolution: {integrity: sha512-Q4r8ghd80yhO/0j1O3B2BjweX3fiHg9cdOwjJd2J76Q135c+NDxGCqdYKQ1SKBuFfgWbAUzBfvYjPUEeNgqN1A==}
@@ -6084,7 +6080,6 @@ packages:
resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==}
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
hasBin: true
dev: true
/natural-compare@1.4.0:
resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==}
@@ -6708,7 +6703,7 @@ packages:
resolution: {integrity: sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==}
engines: {node: ^10 || ^12 || >=14}
dependencies:
nanoid: 3.3.6
nanoid: 3.3.7
picocolors: 1.0.0
source-map-js: 1.0.2
@@ -6782,7 +6777,7 @@ packages:
peerDependencies:
react: '>=16.0.0'
dependencies:
'@types/prismjs': 1.26.1
'@types/prismjs': 1.26.2
clsx: 1.2.1
react: 18.2.0
dev: false
@@ -7269,6 +7264,7 @@ packages:
/shelljs@0.8.5:
resolution: {integrity: sha512-TiwcRcrkhHvbrZbnRcFYMLl30Dfov3HKqzp5tO5b4pt6G/SezKcYhmDg15zXVBswHmctSAQKznqNW2LO5tTDow==}
engines: {node: '>=4'}
hasBin: true
dependencies:
glob: 7.2.3
interpret: 1.4.0
@@ -7736,6 +7732,7 @@ packages:
/tree-cli@0.6.7:
resolution: {integrity: sha512-jfnB5YKY6Glf6bsFmQ9W97TtkPVLnHsjOR6ZdRf4zhyFRQeLheasvzE5XBJI2Hxt7ZyMyIbXUV7E2YPZbixgtA==}
engines: {node: '>=8.10.9'}
hasBin: true
dependencies:
bluebird: 3.4.7
chalk: 1.1.3
@@ -8041,7 +8038,7 @@ packages:
/uri-js@4.4.1:
resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==}
dependencies:
punycode: 2.3.0
punycode: 2.3.1
dev: true
/url-parse@1.5.10: