catcrafts.net/implementations/Catcrafts-Root.cpp
Jorijn van der Graaf 13a12c2a2c Migrate to crafter-build project.cpp and restructure views
- Replace project.json + run.sh with a C++ project.cpp build descriptor
  (crafter-build), targeting wasm32-wasip1 with the Crafter.Graphics dep
- Add Catcrafts-Views implementation; drop Catcrafts-Component
- Add catcrafts-head.js (sets <title>/<link> tags at runtime)
- Update Blog/Root/main modules, README, and favicon

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-18 23:27:41 +02:00

36 lines
1 KiB
C++

/*
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 Crafter.Graphics;
import std;
using namespace Crafter;
namespace Catcrafts {
void RenderRoot(const std::string_view route) {
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("<h1>Post Not Found</h1><p>The requested blog post could not be found.</p>");
}
} else {
RenderBlog();
}
}
}