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>
This commit is contained in:
Jorijn van der Graaf 2026-07-18 23:27:41 +02:00
commit 13a12c2a2c
15 changed files with 227 additions and 126 deletions

View file

@ -1,48 +1,27 @@
/*
catcrafts.net
Copyright (C) 2025 Catcrafts
Copyright (C) 2026 Catcrafts
The source code of this website is made available for viewing purposes only.
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:Views;
import Crafter.CppDOM;
import Crafter.Graphics;
import std;
using namespace Crafter;
export namespace Catcrafts {
HtmlElementPtr body("body", R"(
<header>
<div class="nav-container">
<a href="/" class="logo">🐱 Catcrafts</a>
<nav>
<ul>
<li><a id="blog-nav-button" style="cursor: pointer;" class="active">Blog</a></li>
<li><a href="https://forgejo.catcrafts.net/Catcrafts/">Forgejo</a></li>
</ul>
</nav>
</div>
</header>
// Builds the persistent page chrome (header / <main id="main"> / footer)
// under <body>. Owns the root element for the page's lifetime so its
// children don't get yanked out of the DOM. Must be called from main()
// — the Crafter.Graphics Dom bridge is only safe to use after wasm
// instantiation hands control to user code.
void InitializePage();
<main id="main"></main>
<footer>
<div class="footer-content">
<div class="footer-links">
Powered by Crafter.CppDOM, Running near native with WASM!
<a href="https://forgejo.catcrafts.net/Catcrafts/catcrafts.net">View source</a>
</div>
<p>&copy; 2025 Catcrafts®. All rights reserved. Crafter® and Catcrafts® are registered trademarks with the EUIPO</p>
</div>
</footer>)");
HtmlElementPtr head("head", R"(
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Catcrafts.net</title>
<link rel="stylesheet" href="/styles.css">
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
)");
HtmlElementPtr main("main");
// Per-render scratch ref to the <main> content container created by
// InitializePage(). Looking it up fresh on every call costs one
// document.getElementById; in return we don't have to thread a long-lived
// reference across module boundaries.
inline Dom::HtmlElementPtr MainContent() { return Dom::HtmlElementPtr("main"); }
}