Skip to content

Commit 03a5820

Browse files
committed
feat(email): move email templates into their own package
Pull all email HTML out of the backend and into a standalone `@docs.plus/email-templates` package — one place for every email the app sends. What changed: Created - 5 email template files (.eta) for notifications, digests, new-document alerts, and the unsubscribe page - Shared styles (colors, spacing, fonts) so every email looks consistent without copy-pasting - Reusable building blocks (avatars, buttons, footer links) - Template engine (eta, 2KB) that compiles once and stays fast Moved - Supabase auth templates (magic-link, change-email-address) to hocuspocus.server/templates/ where they belong Cleaned up - Removed ~950 lines of scattered HTML from the backend - Backend now calls simple render functions from the new package - Added 49 tests covering every template and input escaping Also fixed lint-staged to not warn about ESLint-ignored files (--no-warn-ignored) which affected all test files.
1 parent 000b9a1 commit 03a5820

25 files changed

+2360
-956
lines changed

.lintstagedrc.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,16 @@
1313

1414
module.exports = {
1515
// TypeScript/React files in src directories
16-
'packages/**/src/**/*.{ts,tsx}': ['eslint --fix --max-warnings=0', 'prettier --write'],
16+
'packages/**/src/**/*.{ts,tsx}': [
17+
'eslint --fix --max-warnings=0 --no-warn-ignored',
18+
'prettier --write'
19+
],
1720

1821
// JavaScript/React files in src directories
19-
'packages/**/src/**/*.{js,jsx}': ['eslint --fix --max-warnings=0', 'prettier --write'],
22+
'packages/**/src/**/*.{js,jsx}': [
23+
'eslint --fix --max-warnings=0 --no-warn-ignored',
24+
'prettier --write'
25+
],
2026

2127
// Public directory files (service workers, etc.) - format only
2228
'packages/**/public/**/*.{js,ts}': ['prettier --write'],

bun.lock

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/email-templates/change-email-address.html

Lines changed: 0 additions & 80 deletions
This file was deleted.

packages/email-templates/index.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* @docs.plus/email-templates
3+
*
4+
* Extracted, file-based email templates powered by eta (https://eta.js.org).
5+
*
6+
* Templates are .eta files in /templates/ — compiled to native JS functions
7+
* on first use, then cached. Subsequent renders are plain function calls.
8+
*
9+
* Supabase auth templates (magic-link.html, change-email-address.html) use
10+
* Go template syntax and live in packages/hocuspocus.server/templates/ —
11+
* they are NOT managed by this engine.
12+
*
13+
* @example
14+
* ```ts
15+
* import { renderNotificationEmail, getEmailSubject } from '@docs.plus/email-templates'
16+
*
17+
* const html = renderNotificationEmail({
18+
* recipientName: 'Jane',
19+
* senderName: 'John',
20+
* notificationType: 'mention',
21+
* messagePreview: 'Hey @Jane, check the API docs',
22+
* actionUrl: 'https://docs.plus/api-docs?chatroom=general',
23+
* })
24+
* ```
25+
*/
26+
27+
// Render functions
28+
export {
29+
buildListUnsubscribeHeaders,
30+
getEmailSubject,
31+
renderDigestEmail,
32+
renderNewDocumentEmail,
33+
renderNotificationEmail,
34+
renderUnsubscribePage,
35+
} from './src/engine'
36+
37+
// Types & helpers (for consumers that need direct access)
38+
export type { UnsubscribeLinks } from './src/helpers'
39+
export { templateHelpers } from './src/helpers'
40+
export { APP_NAME, APP_URL, COLORS, FONT_STACK,RADIUS, SPACING } from './src/tokens'
41+

packages/email-templates/magic-link.html

Lines changed: 0 additions & 82 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "@docs.plus/email-templates",
3+
"version": "1.0.0",
4+
"private": true,
5+
"description": "Email templates and rendering engine for docs.plus",
6+
"type": "module",
7+
"main": "index.ts",
8+
"scripts": {
9+
"test": "bun test"
10+
},
11+
"dependencies": {
12+
"eta": "^3.5.0"
13+
},
14+
"devDependencies": {
15+
"bun-types": "latest"
16+
}
17+
}

0 commit comments

Comments
 (0)