Skip to content

Commit c6d717a

Browse files
committed
feat(site): add template engine showcase
1 parent 689075e commit c6d717a

10 files changed

Lines changed: 399 additions & 80 deletions

File tree

assets/index-DHE-LPRU.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

assets/index-DS-5ndyh.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 69 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

data/github_stats.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"repo": "vixcpp/vix",
3-
"fetched_at": "2026-05-01T19:17:34.437Z",
3+
"fetched_at": "2026-05-02T09:27:08.428Z",
44
"stars": 413,
55
"forks": 32,
66
"open_issues": 15,

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@
100100
gtag("js", new Date());
101101
gtag("config", "G-1B67VYZMXF");
102102
</script>
103-
<script type="module" crossorigin src="/assets/index-BUQ5y5MO.js"></script>
104-
<link rel="stylesheet" crossorigin href="/assets/index-DHE-LPRU.css">
103+
<script type="module" crossorigin src="/assets/index-fzcikCHZ.js"></script>
104+
<link rel="stylesheet" crossorigin href="/assets/index-DS-5ndyh.css">
105105
<link rel="manifest" href="/manifest.webmanifest"></head>
106106

107107
<body>

sw.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vix-site/public/data/github_stats.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"repo": "vixcpp/vix",
3-
"fetched_at": "2026-05-01T19:17:34.437Z",
3+
"fetched_at": "2026-05-02T09:27:08.428Z",
44
"stars": 413,
55
"forks": 32,
66
"open_issues": 15,

vix-site/src/data/github_stats.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"repo": "vixcpp/vix",
3-
"fetched_at": "2026-05-01T19:17:34.437Z",
3+
"fetched_at": "2026-05-02T09:27:08.428Z",
44
"stars": 413,
55
"forks": 32,
66
"open_issues": 15,

vix-site/src/data/home.js

Lines changed: 78 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ int main()
7676
auto db = vix::db::Database::sqlite("app.db");
7777
7878
db.exec("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)");
79-
8079
db.exec("INSERT INTO users (name) VALUES (?)", "Ada");
8180
8281
auto rows = db.query("SELECT id, name FROM users");
@@ -89,33 +88,39 @@ int main()
8988
label: "WebSocket",
9089
lang: "cpp",
9190
file: "ws.cpp",
92-
code: `#include <vix/websocket.hpp>
91+
code: `#include <vix/websocket/Runtime.hpp>
9392
9493
int main()
9594
{
96-
vix::websocket::Server ws;
95+
vix::config::Config config{".env"};
96+
auto executor = std::make_shared<vix::executor::RuntimeExecutor>(1u);
97+
vix::websocket::Server ws{config, executor};
9798
98-
ws.on_text([](auto&, std::string_view msg) {
99-
// realtime messaging
99+
ws.on_message([](auto &, const std::string &msg) {
100+
// realtime message
100101
});
101102
102-
ws.listen_blocking(9090);
103+
ws.listen_blocking();
103104
}`,
104105
},
105106
{
106107
key: "p2p",
107108
label: "P2P",
108109
lang: "cpp",
109110
file: "p2p.cpp",
110-
code: `#include <vix/p2p/P2P.hpp>
111+
code: `#include <vix/p2p/all.hpp>
111112
112113
int main()
113114
{
114-
vix::p2p::P2PRuntime p2p;
115-
p2p.listen(9001);
115+
vix::p2p::NodeConfig cfg;
116+
cfg.node_id = "node-a";
117+
cfg.listen_port = 9001;
118+
119+
auto node = vix::p2p::make_tcp_node(cfg);
120+
vix::p2p::P2PRuntime p2p(node);
116121
117122
p2p.start();
118-
p2p.wait();
123+
p2p.stop();
119124
}`,
120125
},
121126
],
@@ -137,19 +142,22 @@ int main()
137142
"Write a C++ file, run it directly, and move from prototype to real application without fighting the build system first.",
138143
visual: {
139144
fileName: "main.cpp",
140-
code: `<span class="cpp-directive">#include</span> <span class="cpp-include">&lt;iostream&gt;</span>
145+
code: `<span class="cpp-directive">#include</span> <span class="cpp-include">&lt;vix/print.hpp&gt;</span>
146+
147+
<span class="cpp-keyword">int</span> <span class="cpp-fn">main</span>()
148+
std::vector&lt;<span class="cpp-keyword">int</span>&gt; ports{8080, 9090, 3000};
149+
vix::print(<span class="cpp-string">"Vix is ready"</span>);
141150
142-
<span class="cpp-keyword">int</span> <span class="cpp-fn">main</span>() {
143-
std::cout &lt;&lt; <span class="cpp-string">"Hello, Vix!"</span> &lt;&lt; "\n";
144-
<span class="cpp-keyword">return</span> 0;
151+
vix::print(<span class="cpp-string">"ports:"</span>, ports);
145152
}`,
146153
terminal: `<span class="shell-prompt">$</span> <span class="shell-cmd">vix run</span> main.cpp
147-
Hello, Vix!`,
154+
Vix is ready
155+
ports: [8080, 9090, 3000]`,
148156
},
149157
content: {
150158
title: "Write. Run. Ship.",
151159
badge: "C++ runtime",
152-
text: "Vix removes the early friction from C++ development. Start with a single file, then grow into projects, packages, servers, realtime systems, and production binaries.",
160+
text: "Vix removes the early friction from C++ development. Start with a single file, run it directly, then grow into projects, packages, servers, realtime systems, and production binaries.",
153161
cta: {
154162
label: "More about vix run",
155163
to: "https://docs.vixcpp.com/modules/cli/run",
@@ -168,25 +176,66 @@ Hello, Vix!`,
168176
cards: {
169177
top: {
170178
fileName: "main.cpp",
171-
code: `<span class="cpp-directive">#include</span> <span class="cpp-include">&lt;pdf/pdf.hpp&gt;</span>
179+
code: `<span class="cpp-directive">#include</span> <span class="cpp-include">&lt;cnerium/app/app.hpp&gt;</span>
172180
173-
<span class="cpp-keyword">int</span> <span class="cpp-fn">main</span>() {
174-
pdf::Document doc;
175-
<span class="cpp-keyword">auto</span>&amp; page = doc.add_page();
176-
page.text(50, 759, <span class="cpp-string">"Hello, world!"</span>, pdf::Font::Helvetica, 24);
177-
doc.save(<span class="cpp-string">"hello.pdf"</span>);
181+
<span class="cpp-keyword">int</span> <span class="cpp-fn">main</span>()
182+
{
183+
cnerium::app::App app;
184+
app.listen(<span class="cpp-string">"127.0.0.1"</span>, <span class="cpp-type">8080</span>);
178185
}`,
179186
},
180187
bottom: {
181188
fileName: "terminal",
182-
code: `<span class="shell-path">~$</span> <span class="shell-cmd">vix add</span> <span class="shell-flag">@gk/pdf</span>
183-
<span class="shell-success">✔ added:</span> gk/pdf@0.1.0
184-
185-
<span class="shell-path">~$</span> <span class="shell-cmd">vix install</span>
186-
<span class="shell-success">✔ Dependencies ready</span>
189+
code: `<span class="shell-path">~$</span> <span class="shell-cmd">vix install</span> <span class="shell-flag">-g</span> cnerium/app
190+
<span class="shell-success">✔</span> Installed cnerium/app
187191
188192
<span class="shell-path">~$</span> <span class="shell-cmd">vix run</span> main.cpp
189-
<span class="shell-success">✔ hello.pdf generated</span>`,
193+
<span class="shell-success">✔</span> Running on 127.0.0.1:8080`,
194+
},
195+
},
196+
},
197+
198+
templateEngine: {
199+
title: "Built-in template engine",
200+
subtitle:
201+
"Render dynamic HTML from C++ with variables, loops, conditions, includes, layouts, caching, and streaming.",
202+
badge: "Template",
203+
cta: {
204+
label: "Read template docs",
205+
to: "https://docs.vixcpp.com/modules/template",
206+
},
207+
cards: {
208+
template: {
209+
fileName: "index.html",
210+
code: `<span class="tpl-tag">&lt;h1&gt;</span>{{ title }}<span class="tpl-tag">&lt;/h1&gt;</span>
211+
212+
<span class="tpl-tag">&lt;ul&gt;</span>
213+
{% for feature in features %}
214+
<span class="tpl-tag">&lt;li&gt;</span>{{ feature }}<span class="tpl-tag">&lt;/li&gt;</span>
215+
{% endfor %}
216+
<span class="tpl-tag">&lt;/ul&gt;</span>`,
217+
},
218+
cpp: {
219+
fileName: "main.cpp",
220+
code: `<span class="cpp-directive">#include</span> <span class="cpp-include">&lt;vix.hpp&gt;</span>
221+
<span class="cpp-keyword">using namespace</span> vix;
222+
223+
<span class="cpp-keyword">int</span> <span class="cpp-fn">main</span>()
224+
{
225+
App app;
226+
app.templates(<span class="cpp-string">"./views"</span>);
227+
228+
app.get(<span class="cpp-string">"/"</span>, [](Request &, Response &res) {
229+
vix::template_::Context ctx;
230+
ctx.set(<span class="cpp-string">"title"</span>, <span class="cpp-string">"Template Features"</span>);
231+
vix::template_::Array features;
232+
features.emplace_back(<span class="cpp-string">"Built-in template engine"</span>);
233+
ctx.set(<span class="cpp-string">"features"</span>, features);
234+
res.render(<span class="cpp-string">"index.html"</span>, ctx);
235+
});
236+
237+
app.run(<span class="cpp-type">8080</span>);
238+
}`,
190239
},
191240
},
192241
},
@@ -331,6 +380,7 @@ $ cat vix.lock`,
331380
"Create a project, start dev mode, and begin building native backend, realtime, CLI, or systems applications with Vix.",
332381
code: `vix new api
333382
cd api
383+
vix build
334384
vix dev`,
335385
note: "Start with dev mode, then move to run, package, registry, and deployment workflows as your project grows.",
336386
ctas: [

0 commit comments

Comments
 (0)