Skip to content

feat(demo): add newsletter web archive example (#22)#51

Open
rajarshidattapy wants to merge 1 commit into
unlayer:mainfrom
rajarshidattapy:feat/newsletter-web-archive
Open

feat(demo): add newsletter web archive example (#22)#51
rajarshidattapy wants to merge 1 commit into
unlayer:mainfrom
rajarshidattapy:feat/newsletter-web-archive

Conversation

@rajarshidattapy

Copy link
Copy Markdown

Summary

Adds a newsletter web archive example: the existing NewsletterDigest content rendered as a standalone web page with <Page>, from the same component tree as the email.

Closes #22.

Changes

  • templates/NewsletterDigest.tsx — extracted newsletterTemplate(output), which swaps only the root wrapper (<Email> → tables for inboxes, <Page> → div/flexbox for the browser). Everything between the wrapper tags is shared; the footer links are the one intentional difference (Unsubscribe · View in browser vs Subscribe · Browse the archive).
  • templates/NewsletterWebArchive.tsx — new: the web variant, registered in the template showcase with mode: "web" so it gets Preview / Code / HTML / Plain Text tabs.
  • sections/NewsletterArchiveDemo.tsx — new "Send the email, publish the archive" section rendering both outputs side-by-side with the code that produces them.
  • hooks/useRenderTemplate.ts — honour the entry's declared mode instead of always rendering as email (one line; was a latent bug for any non-email entry).

Test Plan

  • pnpm build passes
  • pnpm test passes (450 tests, 36 files)
  • Tested in Storybook — N/A, demo app only, no library change
  • Added/updated tests for new behavior — see Notes

Notes

Demo-only change; no library code touched. CI type-checks the demo via tsc -b in pnpm build.

Verified the section live in Chromium: both iframes render, no console errors. I also ran a throwaway parity check confirming email emits <table>, web emits none, both carry identical article content, and NewsletterWebArchive() matches newsletterTemplate("web") byte for byte — then deleted it.

Renders the existing NewsletterDigest content as a standalone web page
with <Page>, from the same component tree as the email.

- NewsletterDigest exports newsletterTemplate(output), which swaps only
  the root wrapper: <Email> for inboxes, <Page> for the browser archive.
  Everything between the wrapper tags is shared — the footer links are
  the one intentional difference.
- NewsletterWebArchive is the web variant, registered in the template
  showcase with mode "web".
- New "Send the email, publish the archive" section renders both outputs
  side-by-side with the code that produces them.
- useRenderTemplate now honours the entry's declared mode instead of
  always rendering as email.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Example: Newsletter to Web Archive

1 participant