From ad9efaccd7a547ceb79d9fa585c5e4439eba7b5f Mon Sep 17 00:00:00 2001 From: Maciej Jur Date: Wed, 7 Jun 2023 22:32:23 +0200 Subject: [PATCH] Extract wiki page layout --- src/components/tree/List.astro | 16 +++++++---- src/components/tree/Tree.astro | 6 ++--- src/layouts/Wiki.astro | 48 +++++++++++++++++++++++++++++++++ src/pages/wiki/[...slug].astro | 16 +++-------- src/pages/wiki/index.astro | 18 ------------- src/pages/wiki/index.md | 6 +++++ src/{schema.d.ts => types.d.ts} | 0 src/utils/tree.ts | 8 +++--- 8 files changed, 76 insertions(+), 42 deletions(-) create mode 100644 src/layouts/Wiki.astro delete mode 100644 src/pages/wiki/index.astro create mode 100644 src/pages/wiki/index.md rename src/{schema.d.ts => types.d.ts} (100%) diff --git a/src/components/tree/List.astro b/src/components/tree/List.astro index 1b94109..4838940 100644 --- a/src/components/tree/List.astro +++ b/src/components/tree/List.astro @@ -1,11 +1,11 @@ --- -import { Tree, pathify } from "@utils/tree"; -import type { Maybe } from "purify-ts"; +import { PageTree, pathify } from "@utils/tree"; +import { Maybe } from "purify-ts"; interface Props { - tree: Tree; - slug: string; + tree: PageTree; + slug: Maybe; prefix: Maybe; } @@ -17,6 +17,12 @@ function compare(a: {title: string}, b: {title: string}) { sensitivity: "base", }); } + +function checkCurrent(checked: Maybe) { + return Maybe + .sequence([checked, slug]) + .mapOrDefault(([a, b]) => a == pathify(b), false) +} --- {tree.children @@ -26,7 +32,7 @@ function compare(a: {title: string}, b: {title: string}) {