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:
parent
d87c408712
commit
13a12c2a2c
15 changed files with 227 additions and 126 deletions
|
|
@ -1,30 +1,40 @@
|
|||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
import Catcrafts;
|
||||
import Crafter.CppDOM;
|
||||
import Crafter.Graphics;
|
||||
import std;
|
||||
using namespace Catcrafts;
|
||||
using namespace Crafter;
|
||||
using namespace Crafter::CppDOMBindings;
|
||||
|
||||
HtmlElementView* blogButton;
|
||||
|
||||
int main() {
|
||||
AddPopStateListener([]() {
|
||||
RenderRoot(GetPathNameString());
|
||||
Device::Initialize();
|
||||
// Window in CRAFTER_GRAPHICS_WINDOW_DOM mode is a page-level event hub
|
||||
// plus the rAF driver; even without subscribing to its events we need
|
||||
// it so StartSync() can keep the wasm module alive past main() (the
|
||||
// bridge stashes a raw pointer, so the storage has to outlive main).
|
||||
static Window window(0, 0, "Catcrafts");
|
||||
|
||||
InitializePage();
|
||||
|
||||
Router::AddPopStateListener([]{
|
||||
RenderRoot(Router::GetPath());
|
||||
});
|
||||
|
||||
blogButton = new HtmlElementView("blog-nav-button");
|
||||
blogButton->AddClickListener([](Crafter::MouseEvent e) {
|
||||
PushState("{}", "", "/blog");
|
||||
static Dom::HtmlElementPtr blogButton("blog-nav-button");
|
||||
blogButton.AddClickListener([](Dom::MouseEvent) {
|
||||
Router::PushState("{}", "", "/blog");
|
||||
RenderRoot("/blog");
|
||||
});
|
||||
|
||||
RenderRoot(GetPathNameString());
|
||||
}
|
||||
RenderRoot(Router::GetPath());
|
||||
|
||||
window.StartUpdate();
|
||||
window.StartSync();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue