-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDocsLayout.astro
More file actions
303 lines (276 loc) · 13.8 KB
/
DocsLayout.astro
File metadata and controls
303 lines (276 loc) · 13.8 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
---
import '../styles/global.css';
import Navbar from '../components/Navbar.astro';
import Footer from '../components/Footer.astro';
import { useTranslations, getBaseUrl, getLocalizedPath } from '../i18n/utils';
import type { Lang } from '../i18n/ui';
export interface Props {
title?: string;
description?: string;
canonicalURL?: string;
lang?: Lang;
}
const {
title = 'Docs | AgentCrew',
description = 'AgentCrew documentation. Learn how to build, deploy and orchestrate collaborative AI agent teams.',
canonicalURL = Astro.url.href,
lang = 'en',
} = Astro.props;
const t = useTranslations(lang);
const base = getBaseUrl(lang);
const currentPath = Astro.url.pathname;
const enPath = lang === 'en' ? currentPath : getLocalizedPath(currentPath, 'en');
const esPath = lang === 'es' ? currentPath : getLocalizedPath(currentPath, 'es');
const siteUrl = 'https://agentcrew.sh';
interface NavItem {
href: string;
label: string;
}
interface NavSection {
title: string;
items: NavItem[];
}
const sidebarSections: NavSection[] = [
{
title: t('docs.gettingStarted'),
items: [
{ href: `${base}/docs`, label: t('docs.overview') },
{ href: `${base}/docs/quick-start`, label: t('docs.quickStart') },
{ href: `${base}/docs/configuration`, label: t('docs.configuration') },
],
},
{
title: t('docs.coreConcepts'),
items: [
{ href: `${base}/docs/providers`, label: t('docs.providers') },
{ href: `${base}/docs/open-source-models`, label: t('docs.openSourceModels') },
{ href: `${base}/docs/skills`, label: t('docs.skills') },
{ href: `${base}/docs/schedules`, label: t('docs.schedules') },
{ href: `${base}/docs/webhooks`, label: t('docs.webhooks') },
{ href: `${base}/docs/post-actions`, label: t('docs.postActions') },
{ href: `${base}/docs/mcp`, label: t('docs.mcp') },
{ href: `${base}/docs/authentication`, label: t('docs.authentication') },
{ href: `${base}/docs/architecture`, label: t('docs.architecture') },
],
},
];
const allDocPages = sidebarSections.flatMap((s) => s.items);
const normalizedCurrentPath = currentPath.replace(/\/$/, '');
const currentIndex = allDocPages.findIndex((item) => {
const normalizedHref = item.href.replace(/\/$/, '');
if (normalizedHref === `${base}/docs`) return normalizedCurrentPath === `${base}/docs`;
return normalizedCurrentPath.startsWith(normalizedHref);
});
const prevPage = currentIndex > 0 ? allDocPages[currentIndex - 1] : null;
const nextPage = currentIndex < allDocPages.length - 1 ? allDocPages[currentIndex + 1] : null;
const copyLabel = t('docs.copyCode');
const copiedLabel = t('docs.copied');
const menuOpenLabel = t('docs.sidebarMenuOpen');
const menuCloseLabel = t('docs.sidebarMenuClose');
function isActive(href: string): boolean {
const normalizedHref = href.replace(/\/$/, '');
const normalizedPath = currentPath.replace(/\/$/, '');
if (normalizedHref === `${base}/docs`) {
return normalizedPath === `${base}/docs`;
}
return normalizedPath.startsWith(normalizedHref);
}
---
<!doctype html>
<html lang={lang}>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content={description} />
<meta name="generator" content={Astro.generator} />
<link rel="canonical" href={canonicalURL} />
<link rel="alternate" hreflang="en" href={`${siteUrl}${enPath}`} />
<link rel="alternate" hreflang="es" href={`${siteUrl}${esPath}`} />
<link rel="alternate" hreflang="x-default" href={`${siteUrl}${enPath}`} />
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="og:type" content="website" />
<meta property="og:url" content={canonicalURL} />
<meta property="og:site_name" content="AgentCrew" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content={title} />
<meta name="twitter:description" content={description} />
<meta property="og:image" content={`${siteUrl}/og-image.png`} />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta property="og:image:alt" content={title} />
<meta name="twitter:image" content={`${siteUrl}/og-image.png`} />
<link rel="preconnect" href="https://calendly.com" />
<link rel="dns-prefetch" href="https://github.com" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<meta name="theme-color" content="#0a0f1e" />
<title>{title}</title>
</head>
<body>
<a href="#main-content" class="sr-only focus:not-sr-only focus:fixed focus:top-4 focus:left-4 focus:z-[9999] focus:px-4 focus:py-2 focus:bg-blue-600 focus:text-white focus:rounded-lg focus:outline-none">Skip to content</a>
<Navbar lang={lang} />
<!-- Mobile sidebar toggle -->
<button
id="docs-sidebar-toggle"
class="fixed top-20 left-4 z-40 md:hidden flex items-center gap-2 px-3 py-2 rounded-lg text-sm font-medium text-slate-300 transition-colors duration-200 border border-brand-border"
style="background-color: rgba(15, 23, 42, 0.95);"
aria-label="Toggle documentation sidebar"
>
<svg id="sidebar-icon-open" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
<line x1="3" y1="6" x2="21" y2="6"/>
<line x1="3" y1="12" x2="21" y2="12"/>
<line x1="3" y1="18" x2="21" y2="18"/>
</svg>
<svg id="sidebar-icon-close" class="hidden" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
<line x1="18" y1="6" x2="6" y2="18"/>
<line x1="6" y1="6" x2="18" y2="18"/>
</svg>
<span id="sidebar-toggle-label">Menu</span>
</button>
<!-- Sidebar overlay (mobile) -->
<div
id="docs-sidebar-overlay"
class="fixed inset-0 z-30 hidden md:hidden"
style="background-color: rgba(0, 0, 0, 0.6);"
></div>
<div class="flex pt-16">
<!-- Sidebar -->
<aside
id="docs-sidebar"
class="fixed top-16 left-0 z-30 h-[calc(100vh-4rem)] w-64 overflow-y-auto border-r border-brand-border -translate-x-full md:translate-x-0 transition-transform duration-300 ease-in-out"
style="background-color: #0c1222;"
>
<nav class="px-4 py-6 space-y-6" aria-label="Documentation sidebar">
{sidebarSections.map((section) => (
<div>
<h3 class="text-xs font-semibold uppercase tracking-wider text-slate-500 mb-3 px-2">
{section.title}
</h3>
<ul class="space-y-1">
{section.items.map((item) => (
<li>
<a
href={item.href}
class:list={[
'block px-3 py-2 rounded-md text-sm font-medium transition-colors duration-200',
isActive(item.href)
? 'bg-blue-600/15 text-blue-400 border-l-2 border-blue-400'
: 'text-slate-400 hover:text-white hover:bg-slate-800/50',
]}
>
{item.label}
</a>
</li>
))}
</ul>
</div>
))}
</nav>
</aside>
<!-- Main content -->
<main id="main-content" class="flex-1 md:ml-64 min-h-[calc(100vh-4rem)]">
<div class="max-w-4xl mx-auto px-6 py-12 md:px-12 lg:px-16">
<article class="docs-prose">
<slot />
</article>
<!-- Prev / Next page navigation -->
{(prevPage || nextPage) && (
<nav class="mt-12 pt-8 border-t border-slate-800 flex items-center justify-between gap-4" aria-label="Documentation pagination">
<div class="flex-1">
{prevPage && (
<a
href={prevPage.href}
class="group inline-flex flex-col items-start gap-1 px-4 py-3 rounded-lg border border-slate-800 hover:border-slate-600 hover:bg-slate-800/40 transition-all duration-150 text-left"
>
<span class="text-xs text-slate-500 group-hover:text-slate-400 transition-colors">{t('docs.prevPage')}</span>
<span class="flex items-center gap-2 text-sm font-medium text-slate-300 group-hover:text-white transition-colors">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M19 12H5M12 5l-7 7 7 7"/></svg>
{prevPage.label}
</span>
</a>
)}
</div>
<div class="flex-1 flex justify-end">
{nextPage && (
<a
href={nextPage.href}
class="group inline-flex flex-col items-end gap-1 px-4 py-3 rounded-lg border border-slate-800 hover:border-slate-600 hover:bg-slate-800/40 transition-all duration-150 text-right"
>
<span class="text-xs text-slate-500 group-hover:text-slate-400 transition-colors">{t('docs.nextPage')}</span>
<span class="flex items-center gap-2 text-sm font-medium text-slate-300 group-hover:text-white transition-colors">
{nextPage.label}
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
</span>
</a>
)}
</div>
</nav>
)}
</div>
<Footer lang={lang} />
</main>
</div>
<script define:vars={{ menuOpenLabel, menuCloseLabel, copyLabel, copiedLabel }}>
// ── Sidebar toggle ──────────────────────────────────────────────
const toggle = document.getElementById('docs-sidebar-toggle');
const sidebar = document.getElementById('docs-sidebar');
const overlay = document.getElementById('docs-sidebar-overlay');
const iconOpen = document.getElementById('sidebar-icon-open');
const iconClose = document.getElementById('sidebar-icon-close');
const toggleLabel = document.getElementById('sidebar-toggle-label');
if (toggleLabel) toggleLabel.textContent = menuOpenLabel;
let isOpen = false;
function openSidebar() {
isOpen = true;
sidebar?.classList.remove('-translate-x-full');
sidebar?.classList.add('translate-x-0');
overlay?.classList.remove('hidden');
iconOpen?.classList.add('hidden');
iconClose?.classList.remove('hidden');
if (toggleLabel) toggleLabel.textContent = menuCloseLabel;
toggle?.setAttribute('aria-expanded', 'true');
}
function closeSidebar() {
isOpen = false;
sidebar?.classList.add('-translate-x-full');
sidebar?.classList.remove('translate-x-0');
overlay?.classList.add('hidden');
iconOpen?.classList.remove('hidden');
iconClose?.classList.add('hidden');
if (toggleLabel) toggleLabel.textContent = menuOpenLabel;
toggle?.setAttribute('aria-expanded', 'false');
}
toggle?.addEventListener('click', () => isOpen ? closeSidebar() : openSidebar());
overlay?.addEventListener('click', closeSidebar);
sidebar?.querySelectorAll('a').forEach((link) => {
link.addEventListener('click', () => { if (window.innerWidth < 768) closeSidebar(); });
});
window.addEventListener('resize', () => { if (window.innerWidth >= 768 && isOpen) closeSidebar(); });
// ── Copy buttons for code blocks ────────────────────────────────
document.querySelectorAll('.docs-prose pre').forEach((pre) => {
const wrapper = document.createElement('div');
wrapper.style.position = 'relative';
pre.parentNode?.insertBefore(wrapper, pre);
wrapper.appendChild(pre);
const btn = document.createElement('button');
btn.setAttribute('aria-label', 'Copy code');
btn.innerHTML = `<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg><span>${copyLabel}</span>`;
btn.className = 'copy-code-btn';
wrapper.appendChild(btn);
btn.addEventListener('click', async () => {
const code = pre.querySelector('code');
if (!code) return;
await navigator.clipboard.writeText(code.innerText);
btn.innerHTML = `<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="20 6 9 17 4 12"/></svg><span>${copiedLabel}</span>`;
btn.classList.add('copied');
setTimeout(() => {
btn.innerHTML = `<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg><span>${copyLabel}</span>`;
btn.classList.remove('copied');
}, 2000);
});
});
</script>
</body>
</html>