diff --git a/.gitignore b/.gitignore index 7139420e..8054e1a2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ .moon/cache .eslintcache +.compiled .rendered .test node_modules diff --git a/apps/web/.vitepress/sidebar.mts b/apps/web/.vitepress/sidebar.mts index 769ff870..6b8caed5 100644 --- a/apps/web/.vitepress/sidebar.mts +++ b/apps/web/.vitepress/sidebar.mts @@ -38,6 +38,7 @@ export const sidebar = [ items: [ { text: 'Introduction', link: '/docs/introduction' }, { text: 'Quick Start', link: '/docs/quick-start' }, + { text: 'Recipes', link: '/docs/recipes' }, { text: 'Email Providers', link: '/docs/email-providers' }, { text: 'Email Samples', link: 'https://samples.jsx.email' }, { text: 'FAQ', link: '/docs/faq' }, diff --git a/apps/web/.vitepress/theme/custom.css b/apps/web/.vitepress/theme/custom.css index 3dd0556d..bd42828d 100644 --- a/apps/web/.vitepress/theme/custom.css +++ b/apps/web/.vitepress/theme/custom.css @@ -221,3 +221,13 @@ img.clients { height: auto; } } + +table.recipes { + border-collapse: collapse; +} + +table.recipes td { + border: 0 !important; + padding: 0 10px 0 0 !important; + white-space: nowrap; +} diff --git a/docs/core/compile.md b/docs/core/compile.md new file mode 100644 index 00000000..2d0e6514 --- /dev/null +++ b/docs/core/compile.md @@ -0,0 +1,77 @@ +--- +title: 'Compile' +description: 'Compile jsx-email templates into a bundle' +params: -D +slug: render +type: package +--- + + + + + +## Usage + +```jsx +import { readFile } from 'node:fs/promises;'; +import { resolve } from 'node:path'; + +import { compile } from 'jsx-email'; + +const templatePath = resolve(__dirname, './emails/Batman'); +const outputDir = resolve(__dirname, '.compiled'); + +const compiledFiles = await compile({ files: [templatePath], hashFiles: false, outDir }); +``` + +::: tip +Once compiled into a bundle, the file can be imported and passed to render such like: + +```jsx +import { Template } from './.compiled/batman.js'; + +import { render } from 'jsx-email'; + +const html = render(