Skip to content

Commit bab6eaf

Browse files
Add RSS feed for blog
1 parent d363aee commit bab6eaf

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-1
lines changed

gleam.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ 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"
2628

2729
[dev-dependencies]
2830
gleeunit = ">= 1.0.0 and < 2.0.0"

manifest.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
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" },
56
{ name = "casefold", version = "1.5.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "casefold", source = "hex", outer_checksum = "7DF0295BA71C525FADFBE6C3700C534EDE01ED512138F3EBF00AC158DE3AFF3C" },
67
{ 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" },
78
{ name = "filepath", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "B06A9AF0BF10E51401D64B98E4B627F1D2E48C154967DA7AF4D0914780A6D40A" },
@@ -13,18 +14,22 @@ packages = [
1314
{ name = "gleam_otp", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "BA6A294E295E428EC1562DC1C11EA7530DCB981E8359134BEABC8493B7B2258E" },
1415
{ name = "gleam_regexp", version = "1.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_regexp", source = "hex", outer_checksum = "9C215C6CA84A5B35BB934A9B61A9A306EC743153BE2B0425A0D032E477B062A9" },
1516
{ 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" },
1618
{ name = "gleeunit", version = "1.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "FDC68A8C492B1E9B429249062CD9BAC9B5538C6FBF584817205D0998C42E1DAC" },
1719
{ name = "glexer", version = "2.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "splitter"], otp_app = "glexer", source = "hex", outer_checksum = "40A1FB0919FA080AD6C5809B4C7DBA545841CAAC8168FACDFA0B0667C22475CC" },
1820
{ name = "houdini", version = "1.2.0", build_tools = ["gleam"], requirements = [], otp_app = "houdini", source = "hex", outer_checksum = "5DB1053F1AF828049C2B206D4403C18970ABEF5C18671CA3C2D2ED0DD64F6385" },
1921
{ 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" },
2022
{ name = "mork", version = "1.8.0", build_tools = ["gleam"], requirements = ["casefold", "gleam_regexp", "gleam_stdlib", "splitter"], otp_app = "mork", source = "hex", outer_checksum = "6C48D71DC9DD20F23E63E9422B17F9D12689FB1D47A9DBEF97E982B638C8D1E9" },
2123
{ 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" },
2225
{ name = "simplifile", version = "2.3.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "0A868DAC6063D9E983477981839810DC2E553285AB4588B87E3E9C96A7FB4CB4" },
2326
{ name = "splitter", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "splitter", source = "hex", outer_checksum = "05564A381580395DCDEFF4F88A64B021E8DAFA6540AE99B4623962F52976AA9D" },
2427
{ 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" },
2529
]
2630

2731
[requirements]
32+
birl = { version = ">= 1.8.0 and < 2.0.0" }
2833
contour = { version = ">= 1.2.1 and < 2.0.0" }
2934
filepath = { version = ">= 1.1.2 and < 2.0.0" }
3035
frontmatter = { version = ">= 1.0.1 and < 2.0.0" }
@@ -36,3 +41,4 @@ mork = { version = ">= 1.8.0 and < 2.0.0" }
3641
pearl = { version = ">= 2.2.0 and < 3.0.0" }
3742
simplifile = { version = ">= 2.3.0 and < 3.0.0" }
3843
tom = { version = ">= 1.1.0 and < 2.0.0" }
44+
webls = { version = ">= 1.5.1 and < 2.0.0" }

src/website.gleam

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
import birl
12
import filepath as path
3+
import gleam/int
24
import gleam/io
35
import gleam/list
6+
import gleam/string
47
import lustre/element
58
import simplifile as file
9+
import webls/rss
610
import website/data/blog
711
import website/page/blog_post
812
import website/page/index
@@ -26,6 +30,34 @@ pub fn main() {
2630
create_page("blog/" <> post.slug, blog_post.view(post))
2731
})
2832

33+
let channel =
34+
rss.channel(
35+
"Gears' Blog",
36+
"Blog about programming and Gleam",
37+
"https://gearsco.de",
38+
)
39+
|> rss.with_channel_language("en-gb")
40+
|> rss.with_channel_docs
41+
|> rss.with_channel_items(
42+
list.map(posts, fn(post) {
43+
let assert [year, month, day] =
44+
post.date |> string.split("-") |> list.filter_map(int.parse)
45+
46+
rss.item(post.title, post.description)
47+
|> 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+
)
53+
}),
54+
)
55+
56+
write_file(
57+
write: rss.to_string([channel]),
58+
to: path.join(out_dir, "blog.xml"),
59+
)
60+
2961
io.println("Build succeeded!")
3062
}
3163

src/website/page/index.gleam

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ pub fn my_stuff(posts: List(blog.Post(_))) -> component.Section(_) {
6767
]),
6868
html.p([], list.map(socials, social)),
6969
html.h2([attribute.id("posts")], [
70-
element.text("Posts"),
70+
element.text("Posts • "),
71+
html.a([attribute.href("/blog.xml"), attribute.class("big-link")], [
72+
html.text("RSS Feed"),
73+
]),
7174
]),
7275
],
7376
list.map(posts, post),

0 commit comments

Comments
 (0)