catcrafts.net/interfaces/Catcrafts-Blog.cppm

55 lines
2.5 KiB
Text
Raw Normal View History

2025-11-12 20:58:07 +01:00
/*
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.
*/
export module Catcrafts:Blog;
import Crafter.CppDOM;
import std;
using namespace Crafter;
export namespace Catcrafts {
struct BlogPost {
std::string name;
2025-11-12 21:56:18 +01:00
std::string slug;
2025-11-12 20:58:07 +01:00
std::string date;
std::string content;
};
2025-11-14 23:56:39 +01:00
std::vector<BlogPost> posts {
{
"In WASM, Exit doesn't mean done.",
"in-wasm-exit-doesnt-mean-done",
"2025-11-14",
R"(So if anyone looked at the source code for this website pefore this post you would have seen that every is allocated with new, for example this very blog was defined as <code>std::vector<BlogPost> posts = new std::vector<BlogPost>{...</code><br><br>
Reason for this was that everything became corrupted when callbacking from JS, not knowing sure as to why this was the fastest solution, but after debugging the problem became clear.<br><br>
When we reach the end of <code>int main()</code> from the eyes of C++ we're finished, deconstruct everything and wrap it up. Unkowing that we just registered a bunch of event handlers with JS.<br><br>
This caused all the memory corruption errors since everything was destructed.<br><br>
Luckily this is a very simple fix of adding <code>-fno-c++-static-destructors</code>, and things like this are is also the reason i use clang instead of gcc.<br><br>
So now all examples and this site have been updated to use normal variables again.<br><br>
Stick around for the next post for the <strong>CI/CD nightmare</strong> (not for the faint of heart))"
},
2025-11-12 20:58:07 +01:00
{
2025-11-12 21:02:01 +01:00
"Hello World!",
2025-11-12 21:56:18 +01:00
"hello-world",
2025-11-12 20:58:07 +01:00
"2025-11-12",
2025-11-12 22:40:33 +01:00
R"(Welcome to catcrafts.net!<br><br>
Here we believe optimization is everything and C++ is a gift from god.<br>
This blog will mostly be dedicated to random tidbits i come across while working on my Crafter series of libraries.<br><br>
Like this website which is fully written in C++ using the Crafter.CppDOM library.<br>
And source available too!<br>
<a href="https://forgejo.catcrafts.net/Catcrafts/catcrafts.net">https://forgejo.catcrafts.net/Catcrafts/catcrafts.net<a>)"
2025-11-12 20:58:07 +01:00
}
};
2025-11-12 21:56:18 +01:00
void RenderBlog();
void RenderBlogPost(const std::string_view slug);
2025-11-12 21:24:23 +01:00
}