Render index page for wiki

This commit is contained in:
Maciej Jur 2023-06-06 19:28:01 +02:00
parent 1b5b644356
commit 6c89435b7a
3 changed files with 21 additions and 5 deletions

View file

@ -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>

View file

@ -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>

View 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>