Search
English

How to implement an iframe that shows previews of articles in the admin screen with the same design as the public site(zenn.dev)

startupxo Discuss

Writing language: KoreanRead in the original language

Plain summary

- This is a method published by the development team of MyVision, a Japanese career transition support company. It solves the problem where, when previewing articles from sites with different designs per brand in the admin screen, the admin screen's CSS (design rules) gets applied and colors and other details end up off. - The preview is placed inside an iframe, which is a separate document, and only the CSS of the relevant public site is loaded. React's createPortal renders the content inside the iframe, so the content being edited is passed through as is. The team says it did not modify the shared code that renders articles or the public sites. - CSS is generated in advance for each site by Tailwind v4 when the admin screen is built. If the search base folder is not set to the relevant site, a different CSS is generated without any error, and old CSS may remain because of the Turborepo cache, so the input file must be specified. - For sites that use next/font, the font settings are read from the source and turned into a separate CSS. Link clicks and form submissions inside the preview are blocked. If you change a site's CSS while the development server is running, it is not reflected automatically, so you need to restart the server or run a command.

Read source ↗

Found on

Zenn ↗ / Published by source

Have you run into something like this? Tell us in a line or two what you did. You do not need to know the product.

Sign in to comment

Keyboard shortcuts

Choose a post with J and K or the arrow keys, then press Enter.

K ↑ / J ↓
Previous post / next post
Enter C
Open summary and comments for the selected post
O
Open the original link of the selected post
/
Search
?
Show this help
Tab
Move to the submit or comment button, then press Enter

Type normally in text fields. Tab and Enter are always available.