Skip to content

"Vibe-Trading: Your Personal Trading Agent"

fix(wiki): harden alpha library hydration

Haozhe Wu399b5b4e23d1
diff --git a/wiki/alpha-library/index.html b/wiki/alpha-library/index.html
index 6fdb4a259..f56432e9e 100644
--- a/wiki/alpha-library/index.html
+++ b/wiki/alpha-library/index.html
@@ -30,6 +30,7 @@
<link rel="icon" type="image/png" href="/assets/icon.png">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
+ <link rel="dns-prefetch" href="https://api.github.com">
<link href="https://fonts.googleapis.com/css2?family=Fraunces:opsz,[email protected],600;9..144,750&family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="/styles.css">
<script type="module" src="/main.js"></script>
@@ -56,6 +57,10 @@
</style>
</head>
<body>
+ <noscript>
+ <style>.alpha-stats, .alpha-zoos { display: none; }</style>
+ <p style="padding:24px;color:var(--muted);">Enable JavaScript to load alpha stats.</p>
+ </noscript>
<header class="site-header" id="site-header">
<div class="site-header__inner">
<a class="brand" href="/home/" aria-label="Vibe-Trading home">
@@ -163,7 +168,7 @@ vibe-trading alpha bench --zoo gtja191 --universe csi300 --period 2020-2025</cod
<script>
// Runtime hydration of stats + per-zoo counts from the generated index.json.
(function () {
- fetch("content/index.json", { cache: "no-store" })
+ fetch("content/index.json", { cache: "default" })
.then(function (r) { if (!r.ok) throw new Error("index.json " + r.status); return r.json(); })
.then(function (data) {
var total = document.getElementById("stat-total");
@@ -175,10 +180,14 @@ vibe-trading alpha bench --zoo gtja191 --universe csi300 --period 2020-2025</cod
if (zoos) zoos.textContent = String(data.zoo_count || 0);
if (gen && data.generated_at) {
try { gen.textContent = new Date(data.generated_at).toISOString().slice(0, 10); }
- catch (e) { gen.textContent = String(data.generated_at).slice(0, 10); }
+ catch (e) { gen.textContent = "unknown"; }
}
+ var countEls = Array.prototype.slice.call(document.querySelectorAll(".count[data-zoo]"));
(data.zoos || []).forEach(function (z) {
- var el = document.querySelector('.count[data-zoo="' + z.zoo_id + '"]');
+ var zooId = String(z.zoo_id || "");
+ var el = countEls.find(function (candidate) {
+ return candidate.dataset.zoo === zooId;
+ });
if (el) el.textContent = z.count + " alphas";
});
})