51 lines
No EOL
1.3 KiB
C++
51 lines
No EOL
1.3 KiB
C++
/*
|
|
catcrafts.net
|
|
Copyright (C) 2025 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.
|
|
*/
|
|
|
|
import Catcrafts;
|
|
import Crafter.CppDOM;
|
|
import std;
|
|
using namespace Catcrafts;
|
|
using namespace Crafter;
|
|
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());
|
|
});
|
|
|
|
blogButton = new HtmlElementView("blog-nav-button");
|
|
blogButton->AddClickListener([](Crafter::MouseEvent e) {
|
|
PushState("{}", "", "/blog");
|
|
RenderRoot("blog");
|
|
});
|
|
|
|
RenderRoot("/");
|
|
} |