This commit is contained in:
Jorijn van der Graaf 2025-11-12 21:56:18 +01:00
commit 937b9fb48f
9 changed files with 180 additions and 90 deletions

View file

@ -15,27 +15,6 @@ using namespace Crafter::CppDOMBindings;
HtmlElementView* blogButton;
void RenderRoot(const std::string_view route) {
std::string pageContent;
if(route == "/blog") {
pageContent = RenderBlog();
} else {
pageContent = RenderBlog(); //default route
}
// Set body content
main->SetInnerHTML(pageContent);
// Update active nav link
// auto navLinks = document->GetElementsByClassName("nav-container")[0]->GetElementsByTagName("a");
// for(auto link : navLinks) {
// if(link->GetAttribute("id") == "blog-nav-button") {
// link->SetAttribute("class", "active");
// } else {
// link->SetAttribute("class", "");
// }
//}
}
int main() {
AddPopStateListener([]() {
RenderRoot(GetPathNameString());
@ -44,7 +23,7 @@ int main() {
blogButton = new HtmlElementView("blog-nav-button");
blogButton->AddClickListener([](Crafter::MouseEvent e) {
PushState("{}", "", "/blog");
RenderRoot("blog");
RenderRoot("/blog");
});
RenderRoot("/");