-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathredis-ai-hub-header.js
More file actions
87 lines (81 loc) · 3.43 KB
/
Copy pathredis-ai-hub-header.js
File metadata and controls
87 lines (81 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Redis AI Hub: shared header injector
// Renders a persistent top bar on every per-library docs site.
// In production, this would be injected by the central host (CDN edge or reverse proxy).
// In the prototype, each site bundles this JS and injects on DOMContentLoaded.
(function () {
const HUB_URL = (window.REDIS_AI_HUB_URL || '/').replace(/\/+$/, '/') || '/';
const CURRENT = window.REDIS_AI_HUB_LIBRARY || '';
const LIBRARIES = {
core: [
{ slug: 'redisvl', name: 'RedisVL', path: 'redisvl/' },
{ slug: 'agent-memory', name: 'Agent Memory', path: 'agent-memory/' },
{ slug: 'agent-kit', name: 'Agent Kit', path: 'agent-kit/' },
{ slug: 'sre-agent', name: 'SRE Agent', path: 'sre-agent/' },
],
experimental: [
{ slug: 'sql', name: 'SQL for Redis', path: 'sql/' },
{ slug: 'optimizer', name: 'Retrieval Optimizer', path: 'optimizer/' },
],
integration: [
{ slug: 'adk', name: 'Google ADK', path: 'adk/' },
{ slug: 'langgraph', name: 'LangGraph', path: 'langgraph/' },
{ slug: 'langchain', name: 'LangChain', path: 'langchain/' },
{ slug: 'recipes', name: 'AI Recipes', path: 'recipes/' },
],
};
function dropdown(label, items) {
const links = items.map(it => {
const isCurrent = it.slug === CURRENT;
return `<a href="${HUB_URL}${it.path}" class="rah-item${isCurrent ? ' rah-item--active' : ''}">${it.name}</a>`;
}).join('');
return `
<div class="rah-dropdown">
<button class="rah-dropdown-btn" aria-haspopup="true">${label} <span class="rah-caret">▾</span></button>
<div class="rah-dropdown-menu">${links}</div>
</div>`;
}
function siblingTabs() {
let category = null;
for (const cat of Object.keys(LIBRARIES)) {
if (LIBRARIES[cat].some(l => l.slug === CURRENT)) { category = cat; break; }
}
if (!category) return '';
const tabs = LIBRARIES[category].map(it => {
const isCurrent = it.slug === CURRENT;
return `<a href="${HUB_URL}${it.path}" class="rah-tab${isCurrent ? ' rah-tab--active' : ''}">${it.name}</a>`;
}).join('');
return `<div class="rah-tabs">${tabs}</div>`;
}
function inject() {
if (document.getElementById('rah-header')) return;
const header = document.createElement('div');
header.id = 'rah-header';
header.innerHTML = `
<div class="rah-bar">
<a href="${HUB_URL}" class="rah-brand">
<svg width="22" height="22" viewBox="0 0 24 24" aria-hidden="true">
<circle cx="12" cy="12" r="11" fill="#FF4438"/>
<path d="M7 9l5-3 5 3-5 3-5-3zm0 4l5 3 5-3M7 17l5 3 5-3" stroke="#fff" stroke-width="1.5" fill="none"/>
</svg>
<span>Redis AI</span>
</a>
<nav class="rah-nav">
${dropdown('Libraries', LIBRARIES.core)}
${dropdown('Experimental', LIBRARIES.experimental)}
${dropdown('Integrations', LIBRARIES.integration)}
</nav>
<div class="rah-actions">
<button class="rah-search" onclick="alert('Federated search panel — not wired in prototype')">⌘K Search</button>
<a href="https://github.com/redis" target="_blank" class="rah-gh" aria-label="GitHub">★ GitHub</a>
</div>
</div>
${siblingTabs()}
`;
document.body.insertBefore(header, document.body.firstChild);
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', inject);
} else {
inject();
}
})();