The blog becomes a real CMS: drafts, previews, and a color-tag fix
I moved the last two hardcoded blog posts into the database, so every post is now created and edited from the admin panel. Along the way I fixed a category tag that lost its color in production, stopped the editor from creating duplicate posts, and added a draft preview plus a publish date that stamps when a post actually goes live.
Tooling note: this session ran on Claude Opus 4.8.
A category tag (Misconceptions and Myths) rendered with no color on the live site. The color definitions lived in a types file that the CSS build was never told to scan, so it stripped the classes used only there. Most tags survived by luck, because their exact colors also appeared elsewhere in the code. Adding that folder to the scan list brought the orange tag back and hardened the rest.
I moved the last two posts out of the codebase and into Firestore, so the whole blog is now managed in the admin. The public pages already read from the database, so the real work was deleting the hardcoded copies and pointing the leftover spots (the sitemap and the related-posts list) at the live source instead.
Editing a post and saving again could create a duplicate. After the first save the form never switched into edit mode, so a second save (Save Draft, then Publish) wrote a brand new copy instead of updating the first. Now the form tracks the saved post and updates it.
Finished by checking the draft workflow end to end: drafts stay hidden from the public site, and the security rules back that up. I added a preview so I can see a post exactly as it will render before publishing, and made the publish date set itself on the day a post goes live.
What I learned
- •A CSS build only keeps the class names it can actually see in your files. Put a class somewhere the build does not scan and it gets stripped, even when the code looks right.
- •Most of those tags worked by accident. A coincidence is not coverage, so test the case that has no backup.
- •Moving content into a database is the easy half. The work is the loose ends: every spot that still reads the old source has to move too.
- •A save that does not remember what it just saved will make duplicates. After creating something, switch into edit mode.