/* catcrafts.net Copyright (C) 2026 Catcrafts The source code of this website is made available for viewing purposes only. No permission is granted to copy, modify, distribute, or create derivative works. */ export module Catcrafts:Root_impl; import :Root; import :Views; import :Blog; import :Demo; import Crafter.Graphics; import std; using namespace Crafter; namespace Catcrafts { void RenderRoot(const std::string_view route) { // Every route change replaces
's innerHTML, which would // orphan the demo canvas if it's currently mounted inside a post. // Detach + hide it first; the post renderer re-mounts if needed. UnmountDemo(); std::string currentRoute = std::string(route); if(currentRoute == "/blog" || currentRoute == "/") { RenderBlog(); } else if(currentRoute.rfind("/blog/", 0) == 0) { std::size_t pos = currentRoute.find_last_of('/'); if(pos != std::string::npos) { std::string postSlug = currentRoute.substr(pos + 1); RenderBlogPost(postSlug); } else { MainContent().SetInnerHTML("

Post Not Found

The requested blog post could not be found.

"); } } else { RenderBlog(); } } }