-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathtranscripts.tsx
More file actions
78 lines (75 loc) · 2.14 KB
/
transcripts.tsx
File metadata and controls
78 lines (75 loc) · 2.14 KB
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
import React from "react";
import { add, format, compareDesc, parseISO } from "date-fns";
import { FocusBoundary, Layout, Link } from "@components";
import { loadAllMd, processMd, Transcript } from "@helpers/retrieveMdPages";
export default function Transcripts({
all,
latest,
}: Awaited<ReturnType<typeof getStaticProps>>["props"]) {
const date = format(add(parseISO(latest.date), { days: 1 }), "EEEE PPP");
return (
<Layout
title="Transcripts"
sidebar
as={undefined}
description={`Read transcripts of our past text-based Q&A events, most recently with ${latest.title} on ${date}`}
>
{(setSidebar: any) => (
<>
<h1>{latest.title}</h1>
<FocusBoundary
onChange={setSidebar}
onEnter={undefined}
onExit={undefined}
>
<nav>
<ol>
{all.map((transcript) => (
<li key={transcript.path}>
<Link href={transcript.path}>{transcript.title}</Link>
</li>
))}
</ol>
</nav>
</FocusBoundary>
<div>
<p>
<em>Transcript from {date}</em>
</p>
<div
className="markdown"
dangerouslySetInnerHTML={{ __html: latest.html }}
/>
</div>
</>
)}
</Layout>
);
}
export async function getStaticProps() {
const transcripts = await loadAllMd<Transcript>("src/transcripts");
const all = transcripts
.filter((x) => Boolean(x) && x.content !== "")
.sort((a, b) =>
a.date && b.date ? compareDesc(parseISO(a.date), parseISO(b.date)) : 1,
);
const latest = all[0];
if (!latest) {
throw new Error("No transcripts found!");
}
return {
props: {
all: all.map((t) => ({
title: t.title,
hasContent: Boolean(t.content),
path: `/transcripts/${t.slug}`,
})),
latest: {
title: latest.title,
description: latest.description,
date: latest.date,
html: processMd(latest.content, { wrapFirstList: true }).html,
},
},
};
}