Migrate documentation site to Astro
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
---
|
||||
import { nav } from '../lib/docs.js';
|
||||
import '../style.css';
|
||||
|
||||
const { title = 'Decodal', active = '' } = Astro.props;
|
||||
|
||||
function renderNav(items) {
|
||||
return `<ul class="nav-tree">${items
|
||||
.map((item) => {
|
||||
const href = `/docs/${item.slug}/`;
|
||||
const activeClass = active === item.slug ? ' class="active"' : '';
|
||||
const children = item.children ? renderNav(item.children) : '';
|
||||
return `<li><a${activeClass} href="${href}">${item.title}</a>${children}</li>`;
|
||||
})
|
||||
.join('')}</ul>`;
|
||||
}
|
||||
---
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>{title}</title>
|
||||
</head>
|
||||
<body>
|
||||
<header class="topbar">
|
||||
<a class="brand" href="/docs/introduction/">Decodal</a>
|
||||
<nav class="topnav">
|
||||
<a href="/docs/introduction/">Docs</a>
|
||||
<a href="/playground/">Playground</a>
|
||||
</nav>
|
||||
</header>
|
||||
<div class="layout">
|
||||
<aside class="sidebar">
|
||||
<a class="sidebar-title" href="/docs/">Manual</a>
|
||||
<nav set:html={renderNav(nav)} />
|
||||
</aside>
|
||||
<main class={Astro.props.playground ? 'playground' : ''}>
|
||||
<slot />
|
||||
</main>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user