tangled
alpha
login
or
join now
kacaii.dev
/
blog
0
fork
atom
💻 My personal website
blog.kacaii.dev/
blog
gleam
lustre
0
fork
atom
overview
issues
pulls
pipelines
:truck: rename `post.to_uri_path` to `post.to_kebab_case`
kacaii.dev
2 months ago
1f1ab752
22bdd83b
+6
-6
5 changed files
expand all
collapse all
unified
split
dev
blog_dev.gleam
src
blog
page
content.gleam
posts.gleam
recent_posts.gleam
post.gleam
+1
-1
dev/blog_dev.gleam
···
24
24
let file_path = path.join(posts_path, file_name)
25
25
let assert Ok(post) = post.parse(path: file_path) as "Parse post"
26
26
27
27
-
let new_file_name = post.to_uri_path(post) <> ".md"
27
27
+
let new_file_name = post.to_kebab_case(post) <> ".md"
28
28
let new_file_path =
29
29
string.replace(in: file_path, each: file_name, with: new_file_name)
30
30
+1
-1
src/blog/page/content.gleam
···
12
12
import wisp
13
13
14
14
pub fn handle_request(ctx: web.Context, post_uri: String) -> wisp.Response {
15
15
-
case list.find(ctx.posts, fn(post) { post.to_uri_path(post) == post_uri }) {
15
15
+
case list.find(ctx.posts, fn(post) { post.to_kebab_case(post) == post_uri }) {
16
16
Error(_) -> wisp.not_found()
17
17
Ok(found_post) -> {
18
18
let title = found_post.meta.title
+2
-2
src/blog/page/posts.gleam
···
42
42
class("flex-col p-4 mx-auto w-full rounded-lg shadow-sm bg-ctp-mantle")
43
43
44
44
html.li([li_styles], [
45
45
-
html.a([attr.href("/posts/" <> post.to_uri_path(post))], [
45
45
+
html.a([attr.href("/posts/" <> post.to_kebab_case(post))], [
46
46
html.h2([class("text-2xl font-bold text-left underline text-pretty")], [
47
47
html.text(meta.title),
48
48
]),
···
50
50
51
51
html.p([class("my-2 text-ctp-text")], [html.text(str_date)]),
52
52
html.ul([class("flex flex-wrap gap-2")], list.map(meta.tags, tag_to_li)),
53
53
-
html.hr([class("my-4 border-1 border-ctp-surface0")]),
53
53
+
html.hr([class("my-4 border border-ctp-surface0")]),
54
54
])
55
55
}
56
56
+1
-1
src/blog/page/recent_posts.gleam
···
37
37
string.join([day, month, year], with: " ")
38
38
}
39
39
40
40
-
let href = attr.href("/posts/" <> post.to_uri_path(recent_post))
40
40
+
let href = attr.href("/posts/" <> post.to_kebab_case(recent_post))
41
41
let style = class("flex flex-col p-4 mx-auto w-full rounded-lg bg-ctp-mantle")
42
42
43
43
html.li([style], [
+1
-1
src/blog/post.gleam
···
25
25
Metadata(title: String, date: calendar.Date, tags: List(String))
26
26
}
27
27
28
28
-
pub fn to_uri_path(post: Post) -> String {
28
28
+
pub fn to_kebab_case(post: Post) -> String {
29
29
string.lowercase(post.meta.title)
30
30
|> string.replace(" ", "-")
31
31
|> string.replace("_", "-")