Render index page for wiki
This commit is contained in:
parent
1b5b644356
commit
6c89435b7a
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
import { Tree, pathify } from "@utils/tree";
|
||||
import { Maybe } from "purify-ts";
|
||||
import type { Maybe } from "purify-ts";
|
||||
|
||||
|
||||
interface Props {
|
||||
|
@ -18,9 +18,8 @@ const { tree, prefix } = Astro.props;
|
|||
<ul>
|
||||
{pages.map(page =>
|
||||
<li>
|
||||
{Maybe.of(Maybe.catMaybes([prefix, page.slug]))
|
||||
.filter(xs => xs.length > 0)
|
||||
.map(xs => pathify(...xs))
|
||||
{page.slug
|
||||
.chain(slug => prefix.map(prefix => pathify(prefix, slug)))
|
||||
.mapOrDefault(href =>
|
||||
<a href={href}>{page.title}</a>,
|
||||
<span>{page.title}</span>
|
||||
|
|
|
@ -20,8 +20,8 @@ const { Content } = await entry.render();
|
|||
---
|
||||
|
||||
<Base>
|
||||
<Tree tree={tree} prefix={Maybe.of("/wiki/")}/>
|
||||
<main>
|
||||
<Tree tree={tree} prefix={Maybe.of("/wiki/")}/>
|
||||
<Content />
|
||||
</main>
|
||||
</Base>
|
||||
|
|
17
src/pages/wiki/index.astro
Normal file
17
src/pages/wiki/index.astro
Normal file
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
import Base from "@layouts/Base.astro";
|
||||
import Tree from "@components/tree/Tree.astro";
|
||||
import { collapse } from "@utils/tree";
|
||||
import { getCollection } from "astro:content";
|
||||
import { Maybe } from "purify-ts";
|
||||
|
||||
const tree = collapse(await getCollection('wiki'));
|
||||
|
||||
---
|
||||
|
||||
<Base>
|
||||
<main>
|
||||
<Tree tree={tree} prefix={Maybe.of("wiki")}/>
|
||||
siema
|
||||
</main>
|
||||
</Base>
|
Loading…
Reference in a new issue