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 { Tree, pathify } from "@utils/tree";
|
||||||
import { Maybe } from "purify-ts";
|
import type { Maybe } from "purify-ts";
|
||||||
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
@ -18,9 +18,8 @@ const { tree, prefix } = Astro.props;
|
||||||
<ul>
|
<ul>
|
||||||
{pages.map(page =>
|
{pages.map(page =>
|
||||||
<li>
|
<li>
|
||||||
{Maybe.of(Maybe.catMaybes([prefix, page.slug]))
|
{page.slug
|
||||||
.filter(xs => xs.length > 0)
|
.chain(slug => prefix.map(prefix => pathify(prefix, slug)))
|
||||||
.map(xs => pathify(...xs))
|
|
||||||
.mapOrDefault(href =>
|
.mapOrDefault(href =>
|
||||||
<a href={href}>{page.title}</a>,
|
<a href={href}>{page.title}</a>,
|
||||||
<span>{page.title}</span>
|
<span>{page.title}</span>
|
||||||
|
|
|
@ -20,8 +20,8 @@ const { Content } = await entry.render();
|
||||||
---
|
---
|
||||||
|
|
||||||
<Base>
|
<Base>
|
||||||
<Tree tree={tree} prefix={Maybe.of("/wiki/")}/>
|
|
||||||
<main>
|
<main>
|
||||||
|
<Tree tree={tree} prefix={Maybe.of("/wiki/")}/>
|
||||||
<Content />
|
<Content />
|
||||||
</main>
|
</main>
|
||||||
</Base>
|
</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