Skip to content

Commit cd6e977

Browse files
Update dependencies; Switch from birl to gleam_time
1 parent bab6eaf commit cd6e977

File tree

9 files changed

+58
-62
lines changed

9 files changed

+58
-62
lines changed

blog/bit-array-syntax.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title = "Making the Most of Bit Arrays"
3-
date = "2025-12-18"
3+
date = 2025-12-18
44
description = "Gleam has a special piece of syntax that most other languages don't: Bit arrays. They are extremely powerful, but unfortunately the documentation is a little sparse."
55
---
66

blog/gleam-test-timeouts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title = "Test Timeouts in Gleam"
3-
date = "2025-11-25"
3+
date = 2025-11-25
44
description = "By default, Gleam tests come with a timeout of 5 seconds. It's not as easy as you might think to remove it."
55
---
66

gleam.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ version = "1.0.0"
1515
[dependencies]
1616
gleam_stdlib = ">= 0.44.0 and < 2.0.0"
1717
lustre = ">= 5.0.2 and < 6.0.0"
18-
tom = ">= 1.1.0 and < 2.0.0"
18+
tom = ">= 2.0.0 and < 3.0.0"
1919
simplifile = ">= 2.3.0 and < 3.0.0"
2020
pearl = ">= 2.2.0 and < 3.0.0"
2121
contour = ">= 1.2.1 and < 2.0.0"
2222
mork = ">= 1.8.0 and < 2.0.0"
2323
filepath = ">= 1.1.2 and < 2.0.0"
2424
frontmatter = ">= 1.0.1 and < 2.0.0"
2525
gleam_regexp = ">= 1.1.1 and < 2.0.0"
26-
webls = ">= 1.5.1 and < 2.0.0"
27-
birl = ">= 1.8.0 and < 2.0.0"
26+
webls = { git = "https://github.com/GearsDatapacks/webls", ref = "switch-to-gleam-time" }
27+
gleam_time = ">= 1.6.0 and < 2.0.0"
2828

2929
[dev-dependencies]
3030
gleeunit = ">= 1.0.0 and < 2.0.0"

manifest.toml

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,41 @@
22
# You typically do not need to edit this file
33

44
packages = [
5-
{ name = "birl", version = "1.8.0", build_tools = ["gleam"], requirements = ["gleam_regexp", "gleam_stdlib", "ranger"], otp_app = "birl", source = "hex", outer_checksum = "2AC7BA26F998E3DFADDB657148BD5DDFE966958AD4D6D6957DD0D22E5B56C400" },
6-
{ name = "casefold", version = "1.5.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "casefold", source = "hex", outer_checksum = "7DF0295BA71C525FADFBE6C3700C534EDE01ED512138F3EBF00AC158DE3AFF3C" },
5+
{ name = "casefold", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "casefold", source = "hex", outer_checksum = "F09530B6F771BB7B0BCACD3014089C20DFDA31775BA4793266C3814607C0A468" },
76
{ name = "contour", version = "1.2.1", build_tools = ["gleam"], requirements = ["gleam_community_ansi", "gleam_stdlib", "glexer", "houdini"], otp_app = "contour", source = "hex", outer_checksum = "C7895472BBAAC5D15DBDBAF6DD1847F6981F2F6132F726BAD30434A6E3BAAB95" },
87
{ name = "filepath", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "B06A9AF0BF10E51401D64B98E4B627F1D2E48C154967DA7AF4D0914780A6D40A" },
98
{ name = "frontmatter", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "frontmatter", source = "hex", outer_checksum = "D7FF83A8D22A52867809681EE254A3F989169F92539299958879FE47737DAB7A" },
109
{ name = "gleam_community_ansi", version = "1.4.3", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_regexp", "gleam_stdlib"], otp_app = "gleam_community_ansi", source = "hex", outer_checksum = "8A62AE9CC6EA65BEA630D95016D6C07E4F9973565FA3D0DE68DC4200D8E0DD27" },
1110
{ name = "gleam_community_colour", version = "2.0.2", build_tools = ["gleam"], requirements = ["gleam_json", "gleam_stdlib"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "E34DD2C896AC3792151EDA939DA435FF3B69922F33415ED3C4406C932FBE9634" },
1211
{ name = "gleam_erlang", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "1124AD3AA21143E5AF0FC5CF3D9529F6DB8CA03E43A55711B60B6B7B3874375C" },
13-
{ name = "gleam_json", version = "3.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "874FA3C3BB6E22DD2BB111966BD40B3759E9094E05257899A7C08F5DE77EC049" },
12+
{ name = "gleam_json", version = "3.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "44FDAA8847BE8FC48CA7A1C089706BD54BADCC4C45B237A992EDDF9F2CDB2836" },
1413
{ name = "gleam_otp", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "BA6A294E295E428EC1562DC1C11EA7530DCB981E8359134BEABC8493B7B2258E" },
1514
{ name = "gleam_regexp", version = "1.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_regexp", source = "hex", outer_checksum = "9C215C6CA84A5B35BB934A9B61A9A306EC743153BE2B0425A0D032E477B062A9" },
16-
{ name = "gleam_stdlib", version = "0.65.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "7C69C71D8C493AE11A5184828A77110EB05A7786EBF8B25B36A72F879C3EE107" },
17-
{ name = "gleam_yielder", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_yielder", source = "hex", outer_checksum = "8E4E4ECFA7982859F430C57F549200C7749823C106759F4A19A78AEA6687717A" },
18-
{ name = "gleeunit", version = "1.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "FDC68A8C492B1E9B429249062CD9BAC9B5538C6FBF584817205D0998C42E1DAC" },
15+
{ name = "gleam_stdlib", version = "0.68.1", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "F7FAEBD8EF260664E86A46C8DBA23508D1D11BB3BCC6EE1B89B3BC3E5C83FF1E" },
16+
{ name = "gleam_time", version = "1.6.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_time", source = "hex", outer_checksum = "0DF3834D20193F0A38D0EB21F0A78D48F2EC276C285969131B86DF8D4EF9E762" },
17+
{ name = "gleeunit", version = "1.9.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "DA9553CE58B67924B3C631F96FE3370C49EB6D6DC6B384EC4862CC4AAA718F3C" },
1918
{ name = "glexer", version = "2.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "splitter"], otp_app = "glexer", source = "hex", outer_checksum = "40A1FB0919FA080AD6C5809B4C7DBA545841CAAC8168FACDFA0B0667C22475CC" },
2019
{ name = "houdini", version = "1.2.0", build_tools = ["gleam"], requirements = [], otp_app = "houdini", source = "hex", outer_checksum = "5DB1053F1AF828049C2B206D4403C18970ABEF5C18671CA3C2D2ED0DD64F6385" },
21-
{ name = "lustre", version = "5.3.5", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_json", "gleam_otp", "gleam_stdlib", "houdini"], otp_app = "lustre", source = "hex", outer_checksum = "5CBB5DD2849D8316A2101792FC35AEB58CE4B151451044A9C2A2A70A2F7FCEB8" },
22-
{ name = "mork", version = "1.8.0", build_tools = ["gleam"], requirements = ["casefold", "gleam_regexp", "gleam_stdlib", "splitter"], otp_app = "mork", source = "hex", outer_checksum = "6C48D71DC9DD20F23E63E9422B17F9D12689FB1D47A9DBEF97E982B638C8D1E9" },
20+
{ name = "lustre", version = "5.5.1", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_json", "gleam_otp", "gleam_stdlib", "houdini"], otp_app = "lustre", source = "hex", outer_checksum = "CC01AB1108F7A9F1F96E44B00CBF1D38F0AF46FAF4234B81CED0D4C1835DDBB8" },
21+
{ name = "mork", version = "1.11.1", build_tools = ["gleam"], requirements = ["casefold", "gleam_regexp", "gleam_stdlib", "splitter"], otp_app = "mork", source = "hex", outer_checksum = "2DB4900FCCBB2CF9AB8C8438620FE00FC38CC6D340D52275D10769A4B43B3E5B" },
2322
{ name = "pearl", version = "2.2.0", build_tools = ["gleam"], requirements = ["gleam_community_ansi", "gleam_stdlib", "houdini", "splitter"], otp_app = "pearl", source = "hex", outer_checksum = "E5E14CE725542BA2516570D04140F0D1471761CCE27C6579C6396369FFF1DA9F" },
24-
{ name = "ranger", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_yielder"], otp_app = "ranger", source = "hex", outer_checksum = "C8988E8F8CDBD3E7F4D8F2E663EF76490390899C2B2885A6432E942495B3E854" },
25-
{ name = "simplifile", version = "2.3.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "0A868DAC6063D9E983477981839810DC2E553285AB4588B87E3E9C96A7FB4CB4" },
26-
{ name = "splitter", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "splitter", source = "hex", outer_checksum = "05564A381580395DCDEFF4F88A64B021E8DAFA6540AE99B4623962F52976AA9D" },
27-
{ name = "tom", version = "1.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "tom", source = "hex", outer_checksum = "0910EE688A713994515ACAF1F486A4F05752E585B9E3209D8F35A85B234C2719" },
28-
{ name = "webls", version = "1.5.1", build_tools = ["gleam"], requirements = ["birl", "gleam_stdlib"], otp_app = "webls", source = "hex", outer_checksum = "6C78FFCD3BB888725F83FBD0729BDEA1BFEDFBB06544FCA15BF98FBA04F863B0" },
23+
{ name = "simplifile", version = "2.3.2", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "E049B4DACD4D206D87843BCF4C775A50AE0F50A52031A2FFB40C9ED07D6EC70A" },
24+
{ name = "splitter", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "splitter", source = "hex", outer_checksum = "3DFD6B6C49E61EDAF6F7B27A42054A17CFF6CA2135FF553D0CB61C234D281DD0" },
25+
{ name = "tom", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_time"], otp_app = "tom", source = "hex", outer_checksum = "74D0C5A3761F7A7D06994755D4D5AD854122EF8E9F9F76A3E7547606D8C77091" },
26+
{ name = "webls", version = "1.5.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_time"], source = "git", repo = "https://github.com/GearsDatapacks/webls", commit = "a53611a31765bac8d2a7a8b8fc1a963ccbe599f6" },
2927
]
3028

3129
[requirements]
32-
birl = { version = ">= 1.8.0 and < 2.0.0" }
3330
contour = { version = ">= 1.2.1 and < 2.0.0" }
3431
filepath = { version = ">= 1.1.2 and < 2.0.0" }
3532
frontmatter = { version = ">= 1.0.1 and < 2.0.0" }
3633
gleam_regexp = { version = ">= 1.1.1 and < 2.0.0" }
3734
gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" }
35+
gleam_time = { version = ">= 1.6.0 and < 2.0.0" }
3836
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
3937
lustre = { version = ">= 5.0.2 and < 6.0.0" }
4038
mork = { version = ">= 1.8.0 and < 2.0.0" }
4139
pearl = { version = ">= 2.2.0 and < 3.0.0" }
4240
simplifile = { version = ">= 2.3.0 and < 3.0.0" }
43-
tom = { version = ">= 1.1.0 and < 2.0.0" }
44-
webls = { version = ">= 1.5.1 and < 2.0.0" }
41+
tom = { version = ">= 2.0.0 and < 3.0.0" }
42+
webls = { git = "https://github.com/GearsDatapacks/webls", ref = "switch-to-gleam-time" }

src/website.gleam

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import birl
21
import filepath as path
3-
import gleam/int
42
import gleam/io
53
import gleam/list
6-
import gleam/string
4+
import gleam/time/calendar
5+
import gleam/time/timestamp
76
import lustre/element
87
import simplifile as file
98
import webls/rss
@@ -40,16 +39,13 @@ pub fn main() {
4039
|> rss.with_channel_docs
4140
|> rss.with_channel_items(
4241
list.map(posts, fn(post) {
43-
let assert [year, month, day] =
44-
post.date |> string.split("-") |> list.filter_map(int.parse)
45-
4642
rss.item(post.title, post.description)
4743
|> rss.with_item_link("https://gearsco.de/blog/" <> post.slug)
48-
|> rss.with_item_pub_date(
49-
birl.from_erlang_universal_datetime(
50-
#(#(year, month, day), #(0, 0, 0)),
51-
),
52-
)
44+
|> rss.with_item_pub_date(timestamp.from_calendar(
45+
post.date,
46+
calendar.TimeOfDay(0, 0, 0, 0),
47+
calendar.utc_offset,
48+
))
5349
}),
5450
)
5551

src/website/data/blog.gleam

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import gleam/dict.{type Dict}
44
import gleam/list
55
import gleam/option
66
import gleam/string
7+
import gleam/time/calendar
78
import lustre/element
89
import simplifile
910
import tom.{type Toml}
1011
import website/markdown
1112

1213
pub fn posts() -> List(Post(_)) {
1314
let assert Ok(files) = simplifile.read_directory("blog/")
14-
1515
list.filter_map(files, fn(file) {
1616
use <- bool.guard(!string.ends_with(file, ".md"), Error(Nil))
1717
let file_path = "blog/" <> file
@@ -24,46 +24,26 @@ pub fn posts() -> List(Post(_)) {
2424

2525
let title = get_string_key(metadata, "title")
2626
let description = get_string_key(metadata, "description")
27-
let date = get_string_key(metadata, "date")
27+
let assert Ok(date) = tom.get_date(metadata, ["date"])
28+
2829
// Remove .md suffix
2930
let slug = string.drop_end(file, 3)
3031

31-
let assert [year, month, day] = string.split(date, "-")
32-
let month = case month {
33-
"01" -> "January"
34-
"02" -> "February"
35-
"03" -> "March"
36-
"04" -> "April"
37-
"05" -> "May"
38-
"06" -> "June"
39-
"07" -> "July"
40-
"08" -> "August"
41-
"09" -> "September"
42-
"10" -> "October"
43-
"11" -> "November"
44-
"12" -> "December"
45-
_ -> panic as "Invalid date"
46-
}
47-
48-
let human_date = day <> " " <> month <> ", " <> year
49-
50-
Ok(Post(title:, slug:, date:, human_date:, contents:, description:))
32+
Ok(Post(title:, slug:, date:, contents:, description:))
5133
})
52-
|> list.sort(fn(a, b) { string.compare(b.date, a.date) })
34+
|> list.sort(fn(a, b) { calendar.naive_date_compare(b.date, a.date) })
5335
}
5436

5537
fn get_string_key(toml: Dict(String, Toml), key: String) -> String {
56-
let assert Ok(value) = dict.get(toml, key)
57-
let assert tom.String(value) = value
38+
let assert Ok(value) = tom.get_string(toml, [key])
5839
value
5940
}
6041

6142
pub type Post(a) {
6243
Post(
6344
title: String,
6445
slug: String,
65-
date: String,
66-
human_date: String,
46+
date: calendar.Date,
6747
description: String,
6848
contents: List(element.Element(a)),
6949
)

src/website/markdown.gleam

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import gleam/dict
22
import gleam/list
3+
import gleam/option
34
import gleam/regexp
45
import gleam/string
56
import lustre/attribute.{attribute}
@@ -85,7 +86,8 @@ fn to_id(text: String) -> String {
8586

8687
fn render_inline(inline: document.Inline) -> Element(a) {
8788
case inline {
88-
document.Autolink(uri:) -> anchor([html.text(uri)], uri)
89+
document.Autolink(uri:, text:) ->
90+
anchor([html.text(option.unwrap(text, uri))], uri)
8991
document.CodeSpan(code) -> html.code([], [html.text(code)])
9092
document.EmailAutolink(mail:) -> anchor([html.text(mail)], mail)
9193
document.Emphasis(inlines) -> html.em([], list.map(inlines, render_inline))

src/website/page/blog_post.gleam

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
1+
import gleam/int
2+
import gleam/time/calendar
13
import lustre/attribute
24
import lustre/element
35
import lustre/element/html
46
import website/component
57
import website/data/blog
68

79
pub fn view(post: blog.Post(a)) -> element.Element(a) {
10+
let calendar.Date(year:, month:, day:) = post.date
11+
let date =
12+
int.to_string(day)
13+
<> " "
14+
<> calendar.month_to_string(month)
15+
<> ", "
16+
<> int.to_string(year)
17+
818
component.page(post.title, [
919
component.text_page(post.title, [
1020
html.h2([attribute.class("date")], [
11-
element.text(post.human_date),
21+
element.text(date),
1222
]),
1323
..post.contents
1424
]),

src/website/page/index.gleam

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import gleam/int
12
import gleam/list
3+
import gleam/time/calendar
24
import lustre/attribute
35
import lustre/element.{type Element}
46
import lustre/element/html
@@ -85,6 +87,14 @@ pub fn my_stuff(posts: List(blog.Post(_))) -> component.Section(_) {
8587
}
8688

8789
fn post(post: blog.Post(_)) -> element.Element(_) {
90+
let calendar.Date(year:, month:, day:) = post.date
91+
let date =
92+
int.to_string(day)
93+
<> " "
94+
<> calendar.month_to_string(month)
95+
<> ", "
96+
<> int.to_string(year)
97+
8898
html.div([], [
8999
html.a(
90100
[
@@ -94,7 +104,7 @@ fn post(post: blog.Post(_)) -> element.Element(_) {
94104
[html.text(post.title)],
95105
),
96106
html.br([]),
97-
html.span([attribute.class("bold")], [html.text(post.human_date)]),
107+
html.span([attribute.class("bold")], [html.text(date)]),
98108
html.text(" - " <> post.description),
99109
])
100110
}

0 commit comments

Comments
 (0)