Skip to content

Commit 1be392a

Browse files
authored
Add Lectures page with YAML-based content loading [#41] (#43)
* add placeholder Lectures page and link it to sidebar [#41] * feat: load lectures from src/data/lectures.yml and style page like other sections [#41] * style: fix formatting in lectures.astro to pass Prettier check [#41] * Remove placeholder content from lectures.yml as per feedback
1 parent 503f0bc commit 1be392a

File tree

5 files changed

+65
-1
lines changed

5 files changed

+65
-1
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ const sections = [
2828
icon: "mdi mdi-video",
2929
title: "Lectures",
3030
disabled: false,
31-
link: "https://www.youtube.com/playlist?list=PLY7TEz3ZRQHTnY56q2uJtdXg-bl-c0sDk",
31+
// link: "https://www.youtube.com/playlist?list=PLY7TEz3ZRQHTnY56q2uJtdXg-bl-c0sDk",
32+
link: "/lectures",
3233
},
3334
{ icon: "mdi mdi-creation", title: "Sandbox", disabled: true },
3435
// { icon: "mdi mdi-beaker", title: "Experiments", disabled: true },

src/data/lectures.yml

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

src/pages/lectures.astro

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
import Back from "@components/Back/Back.astro";
3+
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+
}
18+
---
19+
20+
<Layout title="Lectures">
21+
<div class="Question__bar">
22+
<Back href="/" label="Home" />
23+
</div>
24+
25+
<h1>📚 Lectures</h1>
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+
{list.map((lec) => (
36+
<a href={lec.link} target="_blank">
37+
<RowCard title={lec.title} icon="mdi mdi-video" />
38+
</a>
39+
))}
40+
</div>
41+
<div style="margin-top:2.5rem" />
42+
</>
43+
))
44+
}
45+
</Layout>
46+
47+
<style>
48+
p {
49+
color: gray;
50+
}
51+
52+
.Items {
53+
display: flex;
54+
flex-direction: column;
55+
gap: 0.75rem;
56+
}
57+
</style>

0 commit comments

Comments
 (0)