Skip to content

Commit 5b3823d

Browse files
authored
Merge pull request #55 from TeoSlayer/docs/web
docs: update, improve and simplify docs
2 parents f99e6d4 + 56844fc commit 5b3823d

21 files changed

Lines changed: 586 additions & 295 deletions

web/package-lock.json

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

web/src/html/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,10 @@ <h2>Install</h2>
10271027
<p>For bots. Install the agent skills via ClawHub.</p>
10281028
</div>
10291029
</div>
1030+
1031+
<div style="margin-top:20px">
1032+
<a href="/docs/" style="display:inline-block;padding:9px 22px;border-radius:6px;background:var(--accent);color:#000;font-weight:600;font-size:0.85rem;text-decoration:none;transition:opacity 0.15s" onmouseover="this.style.opacity='0.88'" onmouseout="this.style.opacity='1'">Docs →</a>
1033+
</div>
10301034
</section>
10311035

10321036
<!-- FAQ -->

web/src/layouts/DocLayout.astro

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ interface Props {
1414
canonicalPath?: string;
1515
prev?: { label: string; href: string };
1616
next?: { label: string; href: string };
17+
hidePageNav?: boolean;
1718
}
1819
19-
const { title, description, activePage, canonicalPath, prev, next } = Astro.props;
20+
const { title, description, activePage, canonicalPath, prev, next, hidePageNav } = Astro.props;
2021
const canonicalUrl = canonicalPath ? `https://pilotprotocol.network${canonicalPath}` : undefined;
2122
2223
const breadcrumbItems = [
@@ -31,6 +32,7 @@ if (activePage !== 'index') {
3132
<html lang="en">
3233
<head>
3334
<BaseHead title={title} description={description} canonicalUrl={canonicalUrl} />
35+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-tomorrow.min.css" />
3436
<script type="application/ld+json" set:html={JSON.stringify({
3537
"@context": "https://schema.org",
3638
"@type": "WebPage",
@@ -54,11 +56,61 @@ if (activePage !== 'index') {
5456
<body>
5557
<Topbar variant="docs" />
5658
<DocSidebar activePage={activePage} />
59+
<aside class="toc-sidebar" id="toc-sidebar"></aside>
5760
<div class="content">
58-
{activePage !== 'index' && <nav class="breadcrumb" aria-label="Breadcrumb"><a href="/">Home</a> <span class="sep">/</span> <a href="/docs/">Docs</a> <span class="sep">/</span> <span>{title}</span></nav>}
59-
<slot />
60-
<PageNav prev={prev} next={next} />
61+
<div class="content-body">
62+
{activePage !== 'index' && <nav class="breadcrumb" aria-label="Breadcrumb"><a href="/">Home</a> <span class="sep">/</span> <a href="/docs/">Docs</a> <span class="sep">/</span> <span>{title}</span></nav>}
63+
{activePage !== 'index' && (
64+
<a class="back-overview" href="/docs/#flow">
65+
<svg viewBox="0 0 24 24"><line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/></svg>
66+
Flow
67+
</a>
68+
)}
69+
<slot />
70+
{!hidePageNav && <PageNav prev={prev} next={next} />}
71+
</div>
6172
</div>
6273
<DocFooter />
74+
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-core.min.js" defer></script>
75+
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-python.min.js" defer></script>
76+
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-bash.min.js" defer></script>
77+
<script>
78+
(function() {
79+
const sidebar = document.getElementById('toc-sidebar');
80+
if (!sidebar) return;
81+
const content = document.querySelector('.content');
82+
if (!content) return;
83+
const headings = Array.from(content.querySelectorAll('h2[id], h3[id]'));
84+
if (headings.length === 0) return;
85+
86+
const title = document.createElement('div');
87+
title.className = 'toc-title';
88+
title.textContent = 'On this page';
89+
sidebar.appendChild(title);
90+
91+
const links: HTMLAnchorElement[] = [];
92+
headings.forEach(h => {
93+
const a = document.createElement('a');
94+
a.href = '#' + h.id;
95+
a.textContent = h.textContent || '';
96+
if (h.tagName === 'H3') a.classList.add('toc-h3');
97+
sidebar.appendChild(a);
98+
links.push(a);
99+
});
100+
101+
// Scroll spy
102+
const observer = new IntersectionObserver(entries => {
103+
entries.forEach(entry => {
104+
if (entry.isIntersecting) {
105+
links.forEach(l => l.classList.remove('active'));
106+
const active = links.find(l => l.getAttribute('href') === '#' + entry.target.id);
107+
if (active) active.classList.add('active');
108+
}
109+
});
110+
}, { rootMargin: '-56px 0px -60% 0px', threshold: 0 });
111+
112+
headings.forEach(h => observer.observe(h));
113+
})();
114+
</script>
63115
</body>
64116
</html>

0 commit comments

Comments
 (0)