(wiki) basic styles

This commit is contained in:
Maciej Jur 2023-06-06 20:18:12 +02:00
parent 6c89435b7a
commit 741d20c93d
8 changed files with 78 additions and 28 deletions

View file

@ -5,27 +5,32 @@ import type { Maybe } from "purify-ts";
interface Props { interface Props {
tree: Tree; tree: Tree;
slug: string;
prefix: Maybe<string>; prefix: Maybe<string>;
} }
const { tree, prefix } = Astro.props; const { tree, slug, prefix } = Astro.props;
--- ---
{tree.children {tree.children
.map(m => Object.values(m)) .map(m => Object.values(m))
.filter(xs => xs.length > 0) .filter(xs => xs.length > 0)
.map(pages => .map(pages =>
<ul> <ul class="link-tree__nav-list">
{pages.map(page => {pages
<li> .map(page => ({...page, current: page.slug.mapOrDefault(other => other === pathify(slug), false)}))
{page.slug .map(page =>
.chain(slug => prefix.map(prefix => pathify(prefix, slug))) <li class="link-tree__nav-list-item">
.mapOrDefault(href => {page.slug
<a href={href}>{page.title}</a>, .chain(slug => prefix.map(prefix => pathify(prefix, slug)))
<span>{page.title}</span> .mapOrDefault(href =>
)} <a class="link-tree__nav-list-text" class:list={{ current: page.current }} href={href}>
<Astro.self tree={page} prefix={prefix} /> {page.title}
</li> </a>,
<span class="link-tree__nav-list-text">{page.title}</span>
)}
<Astro.self tree={page} slug={slug} prefix={prefix} />
</li>
)} )}
</ul> </ul>
).extract()} ).extract()}

View file

@ -6,21 +6,21 @@ import type { Maybe } from "purify-ts";
interface Props { interface Props {
tree: Tree; tree: Tree;
slug: string;
prefix: Maybe<string>; prefix: Maybe<string>;
} }
const { tree, prefix } = Astro.props; const { tree, slug, prefix } = Astro.props;
--- ---
<aside class="link-tree"> <aside class="link-tree">
<h2 class="link-tree__heading"> <h2 class="link-tree__heading">
{prefix.map(pathify).mapOrDefault(href => {prefix.map(pathify).mapOrDefault(href =>
<a href={href}>Personal wiki</a>, <a class="link-tree__heading-text" href={href}>Personal wiki</a>,
<span>Personal Wiki</span> <span class="link-tree__heading-text">Personal Wiki</span>
)} )}
</h2> </h2>
<section> <nav class="link-tree__nav">
<List tree={tree} prefix={prefix} /> <List tree={tree} slug={slug} prefix={prefix} />
</section> </nav>
</aside> </aside>

View file

@ -1,5 +1,5 @@
--- ---
title: "Hello" title: "TypeScript"
slug: "typescript" slug: "typescript"
--- ---
Hello Hello

View file

@ -1,5 +1,5 @@
--- ---
title: "Hello" title: "Type Challenges"
--- ---
## 4・Pick ## 4・Pick

View file

@ -20,8 +20,10 @@ const { Content } = await entry.render();
--- ---
<Base> <Base>
<main> <main class="main-wiki">
<Tree tree={tree} prefix={Maybe.of("/wiki/")}/> <Tree tree={tree} slug={entry.slug} prefix={Maybe.of("/wiki/")}/>
<Content /> <article>
<Content />
</article>
</main> </main>
</Base> </Base>

View file

@ -6,12 +6,13 @@ import { getCollection } from "astro:content";
import { Maybe } from "purify-ts"; import { Maybe } from "purify-ts";
const tree = collapse(await getCollection('wiki')); const tree = collapse(await getCollection('wiki'));
--- ---
<Base> <Base>
<main> <main class="main-wiki">
<Tree tree={tree} prefix={Maybe.of("wiki")}/> <Tree tree={tree} slug="wiki" prefix={Maybe.of("wiki")} />
siema <article>
siema
</article>
</main> </main>
</Base> </Base>

View file

@ -0,0 +1,41 @@
.main-wiki {
display: grid;
grid-template-columns: 16em 1fr;
}
.link-tree {
padding: 1em;
overflow-y: auto;
&__heading {
border-bottom: 1px solid black;
&-text {
display: block;
text-decoration: unset;
text-align: center;
}
}
&__nav {
&-list {
margin: 0;
padding-left: 0.5em;
list-style: none;
ul {
border-left: 1px solid lightgray;
}
}
// &-list-item {
// }
&-list-text {
text-decoration: unset;
&.current {
text-decoration: underline;
}
}
}
}

View file

@ -12,6 +12,7 @@
@use 'components/lyrics'; @use 'components/lyrics';
@use 'components/song'; @use 'components/song';
@use 'components/album-grid'; @use 'components/album-grid';
@use 'components/link-tree';
// Partials // Partials
@use 'partials/nav'; @use 'partials/nav';