eratic / sites / fav / src / pages / index.astro
223 words
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
---
import Base from '@eratic/core/layouts/Base.astro';
import EntryList from '@eratic/core/components/EntryList.astro';
import { allFavs, favPath, favKicker, kindPath } from '../lib/entries';
import { KINDS, KIND_PLURAL } from '../content.config';

const favs = await allFavs();

// Only offer a filter for a kind that actually has something in it — an empty
// category link is a small broken promise.
const present = KINDS.filter((kind) => favs.some((fav) => fav.data.kind === kind));

const listed = favs.map((fav) => ({
	path: favPath(fav),
	title: fav.data.title,
	summary: fav.data.summary,
	pubDate: fav.data.pubDate,
	kicker: favKicker(fav),
}));
---

<Base site="fav" path="/">
	<header class="intro">
		<h1>fav</h1>
		<p class="intro__text">
			Objects, books, films and music worth keeping, with notes on why.
		</p>

		{
			present.length > 1 && (
				<nav class="kinds" aria-label="Filter by kind">
					<ul>
						{present.map((kind) => (
							<li>
								<a href={kindPath(kind)}>{KIND_PLURAL[kind]}</a>
							</li>
						))}
					</ul>
				</nav>
			)
		}
	</header>

	<EntryList entries={listed} empty="Nothing collected yet." />
</Base>

<style>
	.intro {
		margin-block: var(--space-xl) var(--space-2xl);
		display: flex;
		flex-direction: column;
		gap: var(--space-2xs);
	}

	.intro h1 {
		font-family: var(--font-prose);
		font-size: var(--step-4);
		font-weight: 600;
		line-height: 1.05;
		letter-spacing: -0.022em;
		font-optical-sizing: auto;
	}

	.intro__text {
		font-family: var(--font-prose);
		font-size: var(--step-1);
		color: var(--ink-muted);
		text-wrap: pretty;
	}

	.kinds {
		margin-block-start: var(--space-s);
	}

	.kinds ul {
		display: flex;
		flex-wrap: wrap;
		gap: var(--space-s);
		list-style: none;
		padding: 0;
		margin: 0;
	}

	.kinds a {
		font-family: var(--font-ui);
		font-size: var(--step--1);
		color: var(--ink-muted);
		text-decoration: none;
		border-block-end: 1px solid var(--rule-strong);
		padding-block-end: 1px;
	}

	.kinds a:hover {
		color: var(--ink);
		border-color: var(--ink);
	}
</style>

static mirror of HEAD · about · clone: git clone https://git.makefuture.ro/eratic.git