Skip to content

Commit 0b00648

Browse files
committed
feat: load lectures from src/data/lectures.yml and style page like other sections [#41]
1 parent 6f747f7 commit 0b00648

File tree

5 files changed

+59
-2
lines changed

5 files changed

+59
-2
lines changed

package-lock.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"astro": "^4.11.1",
2222
"axios": "^1.7.7",
2323
"fs": "^0.0.1-security",
24+
"js-yaml": "^4.1.0",
2425
"katex": "^0.16.10",
2526
"mathjax": "^3.2.2",
2627
"mathjax-full": "^3.2.2",

src/components/Sidebar/Sidebar.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const sections = [
2828
icon: "mdi mdi-video",
2929
title: "Lectures",
3030
disabled: false,
31+
// link: "https://www.youtube.com/playlist?list=PLY7TEz3ZRQHTnY56q2uJtdXg-bl-c0sDk",
3132
link: "/lectures",
3233
},
3334
{ icon: "mdi mdi-creation", title: "Sandbox", disabled: true },

src/data/lectures.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
- course: COMP 2804
2+
title: Fall 2020 Lecture
3+
link: https://www.youtube.com/playlist?list=PLY7TEz3ZRQHTnY56q2uJtdXg-bl-c0sDk
4+
5+
- course: COMP 2804
6+
title: KPOP Demon Hunters Playlist
7+
link: https://www.youtube.com/playlist?list=PLxA687tYuMWhg-QcZRiO2eCzkQNN1rEBI

src/pages/lectures.astro

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,59 @@
11
---
22
import Back from "@components/Back/Back.astro";
33
import { default as Layout } from "src/layouts/Content/Content.astro";
4+
import RowCard from "@components/RowCard/RowCard.astro";
5+
import fs from "fs";
6+
import path from "path";
7+
import yaml from "js-yaml";
8+
9+
const filePath = path.resolve("src/data/lectures.yml");
10+
const file = fs.readFileSync(filePath, "utf8");
11+
const lectures = yaml.load(file);
12+
13+
const grouped = {};
14+
for (const lec of lectures) {
15+
if (!grouped[lec.course]) grouped[lec.course] = [];
16+
grouped[lec.course].push(lec);
17+
}
418
---
519

620
<Layout title="Lectures">
721
<div class="Question__bar">
8-
<Back href={`/`} label="Home" />
22+
<Back href="/" label="Home" />
923
</div>
1024

1125
<h1>📚 Lectures</h1>
12-
<p>This is a placeholder page for archived lectures. YAML integration coming soon.</p>
26+
<p>Playlists of recorded lecture videos categorized by course.</p>
27+
28+
<div style="margin-top:2.5rem"></div>
29+
30+
{
31+
Object.entries(grouped).map(([course, list]) => (
32+
<>
33+
<h2>{course}</h2>
34+
<div class="Items">
35+
{
36+
list.map((lec) => (
37+
<a href={lec.link} target="_blank">
38+
<RowCard title={lec.title} icon="mdi mdi-video" />
39+
</a>
40+
))
41+
}
42+
</div>
43+
<div style="margin-top:2.5rem"></div>
44+
</>
45+
))
46+
}
1347
</Layout>
48+
49+
<style>
50+
p {
51+
color: gray;
52+
}
53+
54+
.Items {
55+
display: flex;
56+
flex-direction: column;
57+
gap: 0.75rem;
58+
}
59+
</style>

0 commit comments

Comments
 (0)