Skip to content

Commit 78b1356

Browse files
Add root projects page
1 parent d874957 commit 78b1356

File tree

3 files changed

+50
-7
lines changed

3 files changed

+50
-7
lines changed

src/build.gleam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub fn main() {
2121
|> ssg.add_static_route("/commissions", commissions.view())
2222
|> ssg.add_static_route("/contact", contact.view())
2323
|> ssg.add_static_dir("./static")
24-
|> ssg.add_static_route("/projects", projects_page.view(categories))
24+
|> ssg.add_static_route("/projects/index", projects_page.view(categories))
2525
|> add_dynamic_routes(
2626
categories,
2727
project.view,

src/website.gleam

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/website/page/projects.gleam

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,55 @@
1+
import gleam/dict
2+
import gleam/list
3+
import lustre/attribute.{attribute}
14
import lustre/element.{type Element}
5+
import lustre/element/html
26
import website/component
37
import website/data/projects.{type Category, type Project}
48

59
pub fn view(categories: List(Category)) -> Element(a) {
6-
component.page("Projects", [])
10+
component.text_page(
11+
"Projects",
12+
"My Projects",
13+
list.flat_map(categories, fn(category) {
14+
[
15+
html.h1([attribute.class("text-4xl font-bold text-center p-4 pb-8")], [
16+
html.text(category.title),
17+
]),
18+
html.div(
19+
[
20+
attribute.class(
21+
"grid grid-cols-1 tab:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4 hd:grid-cols-5 gap-96",
22+
),
23+
],
24+
category.projects
25+
|> dict.to_list
26+
|> list.map(fn(pair) {
27+
format_project(category.path, pair.0, pair.1)
28+
}),
29+
),
30+
]
31+
}),
32+
)
33+
}
34+
35+
fn format_project(category: String, id: String, project: Project) -> Element(a) {
36+
html.a([attribute.href("/projects/" <> category <> "/" <> id)], [
37+
html.div(
38+
[
39+
attribute.class(
40+
"w-64 h-64 xs:w-80 xs:h-80 bg-blue-900 rounded-3xl overflow-hidden transition-transform duration-200 hover:scale-105 hover:shadow-2xl shadow-black",
41+
),
42+
],
43+
[
44+
html.img([
45+
attribute.class("max-h-56"),
46+
attribute.alt(project.title),
47+
attribute.src("/images/projects/" <> id <> ".png"),
48+
]),
49+
html.p([attribute.class("text-center py-1.5 text-3xl font-bold")], [
50+
html.text(project.title),
51+
]),
52+
],
53+
),
54+
])
755
}

0 commit comments

Comments
 (0)