Skip to content

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

Merged
ivoIturrieta merged 1 commit into
unlayer:mainfrom
rajarshidattapy:feat/newsletter-web-archive
Jul 27, 2026
Merged

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

Conversation

@rajarshidattapy

Copy link
Copy Markdown
Contributor

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.
@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.50%. Comparing base (adaa68c) to head (aa08d07).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #51   +/-   ##
=======================================
  Coverage   95.50%   95.50%           
=======================================
  Files          31       31           
  Lines        1937     1937           
  Branches      382      382           
=======================================
  Hits         1850     1850           
  Misses         86       86           
  Partials        1        1           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ivoIturrieta ivoIturrieta left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! thanks for the contribution

@ivoIturrieta
ivoIturrieta merged commit 401e8bd into unlayer:main Jul 27, 2026
3 of 4 checks passed
@rajarshidattapy

Copy link
Copy Markdown
Contributor Author

@ivoIturrieta thanks! Will be looking to contribute more :)

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

2 participants