Skip to content

Commit c0cc7b6

Browse files
Refactor to single page
1 parent f00b3b6 commit c0cc7b6

File tree

18 files changed

+71
-226
lines changed

18 files changed

+71
-226
lines changed

projects/datapacks/fungecraft.djot

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

projects/datapacks/gadgets.djot

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

projects/datapacks/lucky-blocks.djot

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

projects/projects.toml

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/build.gleam

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,12 @@
1-
import gleam/dict.{type Dict}
21
import gleam/io
3-
import gleam/list
4-
import lustre/element.{type Element}
52
import lustre/ssg
6-
import website/data/projects
7-
import website/page/about
8-
import website/page/contact
93
import website/page/index
10-
import website/page/project
11-
import website/page/projects as projects_page
124

135
pub fn main() {
14-
let categories = projects.all()
15-
166
let build =
177
ssg.new("./priv")
188
|> ssg.add_static_route("/", index.view())
19-
|> add_static_route("/about", about.view())
20-
|> add_static_route("/contact", contact.view())
219
|> ssg.add_static_dir("./static")
22-
|> add_static_route("/projects", projects_page.view(categories))
23-
|> add_dynamic_routes(
24-
categories,
25-
project.view,
26-
fn(category: projects.Category(a)) {
27-
#("/projects/" <> category.path, category.projects)
28-
},
29-
)
3010
|> ssg.build
3111

3212
case build {
@@ -37,22 +17,3 @@ pub fn main() {
3717
}
3818
}
3919
}
40-
41-
fn add_dynamic_routes(
42-
config: ssg.Config(a, b, c),
43-
list: List(d),
44-
view: fn(e) -> Element(f),
45-
map_fn: fn(d) -> #(String, Dict(String, e)),
46-
) -> ssg.Config(a, b, c) {
47-
use config, element <- list.fold(list, config)
48-
let #(base, dict) = map_fn(element)
49-
ssg.add_dynamic_route(config, base, dict, view)
50-
}
51-
52-
fn add_static_route(
53-
config: ssg.Config(a, b, c),
54-
route: String,
55-
view: Element(d),
56-
) -> ssg.Config(ssg.HasStaticRoutes, b, c) {
57-
ssg.add_static_route(config, route <> "/index", view)
58-
}

src/website/component.gleam

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import gleam/list
12
import lustre/attribute.{attribute}
23
import lustre/element.{type Element}
34
import lustre/element/html
@@ -33,23 +34,26 @@ pub fn head(page: String) -> Element(a) {
3334
])
3435
}
3536

36-
pub fn page(name: String, content: List(Element(a))) -> Element(a) {
37+
pub type Section(a) {
38+
Section(content: List(Element(a)))
39+
}
40+
41+
pub fn page(name: String, sections: List(Section(a))) -> Element(a) {
3742
html.html([attribute("lang", "en")], [
3843
head(name),
3944
html.body([attribute.class("min-h-screen bg-slate-800 text-white")], [
40-
header.view(name),
41-
html.main([attribute.class("py-24")], content),
45+
header.view(),
46+
html.main(
47+
[attribute.class("py-24")],
48+
list.flat_map(sections, fn(section) { section.content }),
49+
),
4250
footer.view(),
4351
]),
4452
])
4553
}
4654

47-
pub fn text_page(
48-
title: String,
49-
header: String,
50-
content: List(Element(a)),
51-
) -> Element(a) {
52-
page(title, [
55+
pub fn text_page(header: String, content: List(Element(a))) -> Section(a) {
56+
Section([
5357
html.div([attribute.class("mx-auto max-w-3xl")], [
5458
html.h1(
5559
[attribute.class("text-3xl font-bold leading-tight text-center")],

src/website/component/footer.gleam

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,46 @@ import lustre/attribute
33
import lustre/element.{type Element}
44
import lustre/element/html
55

6-
type Social {
7-
Social(icon: String, name: String, url: String)
6+
pub type Social {
7+
Social(icon: String, name: String, url: String, description: String)
88
}
99

10-
const socials = [
10+
pub const socials = [
1111
Social(
1212
icon: "youtube.png",
1313
name: "YouTube",
1414
url: "https://youtube.com/@GearsDatapacks",
15+
description: "Videos on Minecraft Datapacks and Gleam",
1516
),
1617
Social(
1718
icon: "github.png",
1819
name: "Github",
1920
url: "https://github.com/GearsDatapacks",
21+
description: "All my projects",
2022
),
2123
Social(
2224
icon: "bluesky.svg",
2325
name: "Bluesky",
2426
url: "https://bsky.app/profile/gearsco.de",
27+
description: "Random social media posting",
2528
),
2629
Social(
2730
icon: "modrinth.svg",
2831
name: "Modrinth",
2932
url: "https://modrinth.com/user/GearsDatapacks",
33+
description: "Minecraft datapacks",
3034
),
3135
Social(
3236
icon: "discord.png",
3337
name: "Discord",
3438
url: "https://discord.gg/fmPKDqf9ze",
39+
description: "Discord Server",
40+
),
41+
Social(
42+
icon: "hex.png",
43+
name: "Hex",
44+
url: "https://hex.pm/users/Gears",
45+
description: "Gleam libraries",
3546
),
3647
]
3748

src/website/component/header.gleam

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
1-
import gleam/list
21
import lustre/attribute.{attribute}
32
import lustre/element.{type Element}
43
import lustre/element/html
54
import lustre/element/svg
65

7-
type PageRoute {
8-
PageRoute(name: String, url: String)
9-
}
10-
11-
const pages = [
12-
PageRoute("About", "/about"),
13-
PageRoute("Projects", "/projects"),
14-
PageRoute("Contact me", "/contact"),
15-
]
16-
17-
pub fn view(page: String) -> Element(a) {
6+
pub fn view() -> Element(a) {
187
html.header([attribute.class("bg-purple-700 flex w-full select-none fixed")], [
198
html.nav(
209
[
@@ -63,44 +52,9 @@ pub fn view(page: String) -> Element(a) {
6352
],
6453
),
6554
]),
66-
nav_bar(page),
6755
],
6856
),
6957
])
7058
}
7159

72-
fn nav_bar(current_page: String) -> Element(a) {
73-
html.ul(
74-
[attribute.class("flex space-x-4")],
75-
list.map(pages, fn(page) {
76-
let default_style = "text-xl font-bold border-2 p-2"
77-
let element = case page.name == current_page {
78-
True ->
79-
html.span(
80-
[
81-
attribute.class(
82-
default_style
83-
<> " cursor-default border-gray-400 text-gray-400 text-xs lg:text-xl",
84-
),
85-
],
86-
[element.text(page.name)],
87-
)
88-
False ->
89-
html.a(
90-
[
91-
attribute.class(
92-
default_style
93-
<> " border-cyan-500 text-cyan-300 ease-linear duration-75 hover:underline text-xs lg:text-xl hover:text-xl hover:lg:text-2xl",
94-
),
95-
attribute.style("transition-property", "font-size"),
96-
attribute.href(page.url),
97-
],
98-
[element.text(page.name)],
99-
)
100-
}
101-
html.li([], [element])
102-
}),
103-
)
104-
}
105-
10660
const logo_svg = "m 46.655648,87.273021 c 0.08105,4.602277 0.692125,6.832404 4.69733,4.361206 l 1.696146,2.728148 -14.225762,9.638735 c -2.121146,-1.55607 -3.838276,-4.0442 -4.678364,-7.342384 -3.390161,3.734254 -7.562386,6.271464 -13.082724,5.788494 C 10.581627,101.53029 2.8720353,90.133692 1.4418114,77.915968 0.26959238,64.592176 8.4519982,56.762609 16.647423,50.627146 c 6.709353,-4.814367 12.185664,-6.592535 16.425926,-6.221561 10.400636,0.909937 10.2848,16.055858 17.661218,12.831577 l 1.369105,2.78015 -13.921761,7.085583 C 29.896397,65.974923 28.524127,49.408937 19.629655,55.241389 c -4.548238,3.149245 -6.106269,8.978614 -4.24704,19.057204 1.461159,6.335369 5.770507,14.209799 12.214927,17.030887 2.403158,1.097035 4.205262,0.770993 6.046357,-0.922122 l 0.08399,-0.960053 0.300983,-3.440212 c -4.7513,-0.980005 -7.300468,-2.251058 -10.07761,0.0051 L 22.053124,83.749873 33.3637,74.259168 c 9.7606,0.853945 14.332923,4.801125 19.271184,0.879838 l 1.905129,2.18211 -7.907394,7.450543 c -0.0043,0.967047 0.07203,1.94111 0.02303,2.501151 z m 27.106123,0.967939 c 3.255101,3.879267 7.924879,5.594901 14.610274,2.013462 L 89.84759,92.997687 71.511182,104.62772 C 62.371276,103.58301 53.002118,82.748534 59.5709,73.029912 61.983775,69.728218 72.927415,59.493724 79.332135,60.054064 85.49365,60.593125 92.577447,70.199104 92.109323,75.549881 Z M 70.902742,68.629587 c -3.536763,2.141364 -1.750046,9.73174 1.253752,15.549655 L 79.558343,78.94493 C 78.612783,73.878931 74.248977,66.798328 70.902742,68.629587 Z m 62.806708,23.029124 1.74528,2.221251 -13.08952,10.709588 c -2.6179,0 -5.2358,-4.839141 -5.71178,-8.567661 l -11.7409,8.567661 c -6.505075,-0.0794 -10.709601,-7.61571 -9.916305,-13.24816 1.269292,-8.250355 9.123005,-13.010178 19.832605,-16.104062 -3.49054,-5.553124 -13.08951,-4.997811 -19.0393,-1.348612 l -1.586601,-2.459244 14.993441,-10.78893 c 9.28166,0 19.19795,1.665941 19.43593,14.438129 l 0.0794,12.375534 c -0.0794,4.125169 1.26928,6.901741 4.99782,4.204506 z m -22.60914,3.490534 4.99781,-3.252544 -0.0794,-12.930849 c -10.23362,3.728531 -10.70961,12.930849 -4.91847,16.183393 z m 51.19467,-16.075266 c -2.21157,-3.712255 -5.13397,-8.846224 -8.45131,-5.765843 l -0.47391,0.473911 v 1.184756 l 0.079,12.795432 c -0.079,4.028194 1.18475,6.555693 4.897,3.949214 l 1.81664,2.448509 -13.0324,10.504892 c -3.55428,-2.21157 -6.23973,-6.792636 -6.16074,-13.664255 V 78.679058 c -0.15797,-4.818028 -1.97461,-6.397712 -6.63468,-3.396316 L 132.99186,72.755248 147.13,60.907625 c 3.08039,2.290541 4.89704,4.423114 5.68687,7.740447 l 8.05639,-7.740447 c 6.00279,0 11.68966,9.636068 11.68966,9.636068 z m 19.14678,-9.156439 c 4.4536,7.601839 23.80372,5.375035 23.80372,20.962647 0,10.442913 -10.13577,13.207223 -19.5037,13.207223 -7.14112,0 -13.8983,-2.45716 -16.12512,-6.757188 l 11.36438,-10.596498 1.84287,1.45894 c -2.91787,2.841084 11.134,6.987545 15.05009,6.987545 0.46073,-6.296472 -26.33768,-10.058994 -26.33768,-19.580489 0,-8.369699 13.89831,-14.05188 13.89831,-14.05188 7.83221,0 16.2019,4.4536 21.11622,1.61251 l 1.22858,1.689298 -12.90008,10.289358 c -4.99112,0 -11.44115,-8.292917 -13.43759,-5.221466 z"

src/website/page/about.gleam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import lustre/element/html
33
import website/component
44

55
pub fn view() {
6-
component.text_page("About", "About me", [
6+
component.text_page("About me", [
77
html.span([attribute.class("font-bold")], [
88
html.text("I'm Gears, an amateur software developer, and general nerd."),
99
]),

src/website/page/contact.gleam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import lustre/element/html
33
import website/component
44

55
pub fn view() {
6-
component.text_page("Contact me", "Contact me", [
6+
component.text_page("Contact me", [
77
html.text(
88
"If you have questions you want to ask, or want to reach out to me, you can send me an email at ",
99
),

0 commit comments

Comments
 (0)