Every email the site sends shares one layout: the site's emoji and name, then a card holding the content, then a footer. The templates beside this module (welcome, password reset, digest) build their content with an EmailKit, which draws each block in a style from styles.ts, and email-service.ts sends what they return.

Mail clients drop stylesheets, so every block carries inline styles. A reader on the "auto" scheme gets the light palette inline and the dark one in a prefers-color-scheme block that Apple's mail apps honour; elsewhere the light one shows.

Classes

c
EmailKit(look: EmailLook)

Draws an email in one EmailLook. A template writes the email as Markdown and hands it to EmailKit.render, which draws each block in the style. The block methods return HTML: text passed to them must already be escaped with esc.

Functions

f
esc(value: string): string

Escapes value for HTML text and attributes. Everything users wrote (names, titles, quotes) goes through it, since none of it may become markup.

f
escMd(value: string): string

Escapes value for Markdown, so that user text in a plain-text part (a title with * or [, say) stays text.

f
lookOf(settings?: Pick<UserSettings, "style" | "colorScheme"> | null): EmailLook

Returns the look of a reader's settings. An unset style is the instance's, as on the site, and an unset scheme the system's; with no settings at all, as for the welcome and reset emails, both are.

Interfaces

I
EmailLook

Passed to EmailKit, made by lookOf: the instance's style for the emails that aren't a user's own, their settings for a digest.

I
RenderedEmail

Returned by each template to its caller, which hands it to sendEmail with a recipient.

Type Aliases

T
PaletteRole = Exclude<keyof EmailPalette, "gradient">

Names a color of an EmailPalette, as EmailKit.paint takes it, so that the dark block can recolor the element by the same name.