(wiki) cleanup

This commit is contained in:
Maciej Jur 2023-06-06 21:34:16 +02:00
parent c3e732303c
commit 210b5ef8a5
13 changed files with 17 additions and 100 deletions

View file

@ -1,6 +1,5 @@
--- ---
interface MenuItem { interface MenuItem {
identifier: string;
name: string; name: string;
url: string; url: string;
} }
@ -8,42 +7,34 @@ interface MenuItem {
/** Config for the menu displayed in site navbar. */ /** Config for the menu displayed in site navbar. */
const menu: MenuItem[] = [ const menu: MenuItem[] = [
{ {
identifier: 'posts',
name: 'Posts', name: 'Posts',
url: '/posts/', url: '/posts/',
}, },
{ {
identifier: 'repos',
name: 'Repos', name: 'Repos',
url: '/repos/', url: '/repos/',
}, },
{ {
identifier: 'slides',
name: 'Slides', name: 'Slides',
url: '/slides/', url: '/slides/',
}, },
{ {
identifier: 'aoc', name: 'Wiki',
name: 'AoC', url: '/wiki/',
url: '/aoc/',
}, },
{ {
identifier: 'songs',
name: 'Songs', name: 'Songs',
url: '/songs/', url: '/songs/',
}, },
{ {
identifier: 'map',
name: 'Map', name: 'Map',
url: '/map/', url: '/map/',
}, },
{ {
identifier: 'about',
name: 'About', name: 'About',
url: '/about/', url: '/about/',
}, },
{ {
identifier: 'search',
name: 'Search', name: 'Search',
url: '/search/' url: '/search/'
} }

View file

@ -5,19 +5,20 @@ import type { Maybe } from "purify-ts";
interface Props { interface Props {
heading: string;
tree: Tree; tree: Tree;
slug: string; slug: string;
prefix: Maybe<string>; prefix: Maybe<string>;
} }
const { tree, slug, prefix } = Astro.props; const { heading, 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 class="link-tree__heading-text" href={href}>Personal wiki</a>, <a class="link-tree__heading-text" href={href}>{heading}</a>,
<span class="link-tree__heading-text">Personal Wiki</span> <span class="link-tree__heading-text">{heading}</span>
)} )}
</h2> </h2>
<nav class="link-tree__nav"> <nav class="link-tree__nav">

View file

@ -9,16 +9,6 @@ export const collections = {
tags: z.array(z.string()).optional(), tags: z.array(z.string()).optional(),
}) })
}), }),
aoc: defineCollection({
schema: z.object({
title: z.string(),
date: z.date(),
day: z.number(),
stars: z.number(),
math: z.boolean().optional(),
tags: z.array(z.string()).optional(),
})
}),
slides: defineCollection({ slides: defineCollection({
schema: z.object({ schema: z.object({
title: z.string(), title: z.string(),

View file

@ -1,6 +1,5 @@
--- ---
title: Quotes title: Quotes
date: 2023-05-01
--- ---
A collection of quotes I've found pretty memorable. A collection of quotes I've found pretty memorable.

View file

@ -1,6 +1,5 @@
--- ---
title: Recommended reading title: Recommended Reading
date: 2023-06-01T20:02:20.239Z
--- ---
## Programming ## Programming

View file

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

View file

@ -4,7 +4,7 @@ title: "Type Challenges"
## 4・Pick ## 4・Pick
> Implement the built-in `Pick<T, K>` generic without using it. Constructs a type by picking the set of properties `K` from `T`. Implement the built-in `Pick<T, K>` generic without using it. Constructs a type by picking the set of properties `K` from `T`.
```ts ```ts
type MyPick<T, K extends keyof T> = { type MyPick<T, K extends keyof T> = {
@ -15,7 +15,7 @@ type MyPick<T, K extends keyof T> = {
## 7・Readonly ## 7・Readonly
> Implement the built-in `Readonly<T>` generic without using it. Constructs a type with all properties of T set to readonly, meaning the properties of the constructed type cannot be reassigned. Implement the built-in `Readonly<T>` generic without using it. Constructs a type with all properties of T set to readonly, meaning the properties of the constructed type cannot be reassigned.
```ts ```ts
type MyReadonly<T> = { type MyReadonly<T> = {
@ -26,7 +26,7 @@ type MyReadonly<T> = {
## 11・Tuple to Object ## 11・Tuple to Object
> Given an array, transform it into an object type and the key/value must be in the provided array. Given an array, transform it into an object type and the key/value must be in the provided array.
```ts ```ts
type TupleToObject<T extends readonly (string | number)[]> = { type TupleToObject<T extends readonly (string | number)[]> = {

View file

@ -1,15 +0,0 @@
---
import Article from '../../layouts/Article.astro';
import { getCollection } from 'astro:content';
export async function getStaticPaths() {
return (await getCollection('aoc'))
.map(entry => ({params: {slug: entry.slug}, props: {entry}}));
}
const { entry } = Astro.props;
const { Content, headings } = await entry.render();
---
<Article frontmatter={entry.data} headings={headings}>
<Content />
</Article>

View file

@ -1,24 +0,0 @@
---
import List from '../../layouts/List.astro';
import { getCollection } from 'astro:content';
import dayjs from 'dayjs';
export async function getStaticPaths () {
return [...new Set((await getCollection('aoc')).map(e => e.slug.slice(0, 4)))]
.map(year => ({params: {year}, props: {year}}))
}
const { year } = Astro.props;
const content = await getCollection('aoc', (entry) => entry.id.startsWith(year));
const pages = content
.map(doc => ({
title: `Day ${doc.data.day}`,
slug: `/aoc/${doc.slug}/`,
date: dayjs(doc.data.date),
}));
---
<List title={year} pages={pages} />

View file

@ -1,21 +0,0 @@
---
import List from '../../layouts/List.astro';
import { getCollection } from 'astro:content';
const content = await getCollection('aoc');
const occ: {[key: string]: number} = {}
for (const doc of content) {
const year = doc.slug.slice(0, 4);
(year in occ) ? occ[year] += 1 : occ[year] = 1;
}
const pages = Object.entries(occ)
.map(([year, occ]) => ({
title: `${year} - ${occ} days`,
slug: `/aoc/${year}/`,
}));
---
<List title="Advent of Code" pages={pages} />

View file

@ -21,8 +21,9 @@ const { Content } = await entry.render();
<Base> <Base>
<main class="main-wiki"> <main class="main-wiki">
<Tree tree={tree} slug={entry.slug} prefix={Maybe.of("/wiki/")}/> <Tree heading="Personal Wiki" tree={tree} slug={entry.slug} prefix={Maybe.of("/wiki/")}/>
<article> <article class="markdown">
<h1>{entry.data.title}</h1>
<Content /> <Content />
</article> </article>
</main> </main>

View file

@ -10,7 +10,7 @@ const tree = collapse(await getCollection('wiki'));
<Base> <Base>
<main class="main-wiki"> <main class="main-wiki">
<Tree tree={tree} slug="wiki" prefix={Maybe.of("wiki")} /> <Tree heading="Personal Wiki" tree={tree} slug="wiki" prefix={Maybe.of("wiki")} />
<article> <article>
siema siema
</article> </article>

View file

@ -1,6 +1,6 @@
.main-wiki { .main-wiki {
display: grid; display: grid;
grid-template-columns: 16em 1fr; grid-template-columns: 16em 1fr 16em;
} }
.link-tree { .link-tree {
@ -8,7 +8,8 @@
overflow-y: auto; overflow-y: auto;
&__heading { &__heading {
border-bottom: 1px solid black; border-bottom: 1px solid;
border-image: linear-gradient(to right, transparent, var(--c-primary), transparent) 1;
&-text { &-text {
display: block; display: block;