My website lesbian.skin
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add posts overview

+71 -17
+57 -7
src/website.gleam
··· 1 + import birl.{type Day} 2 + import gleam/int 1 3 import gleam/list 2 4 import gleam/string 3 5 import gleam/uri.{type Uri} ··· 27 29 type Model { 28 30 Model( 29 31 current_route: Route, 30 - posts: List(posts.Post), 32 + posts: List(posts.Post(Msg)), 31 33 projects: List(projects.Project(Msg)), 32 34 ) 33 35 } ··· 55 57 56 58 fn init(_flags) -> #(Model, Effect(Msg)) { 57 59 #( 58 - Model(current_route: get_route(), projects: projects.all(), posts: []), 60 + Model( 61 + current_route: get_route(), 62 + projects: projects.all(), 63 + posts: posts.all(), 64 + ), 59 65 modem.init(on_route_change), 60 66 ) 61 67 } ··· 102 108 Projects -> view_projects(model) 103 109 Project(id) -> view_project(model, id) 104 110 Posts -> view_posts(model) 105 - _ -> view_home(model) 111 + Post(id) -> view_post(model, id) 106 112 } 107 113 108 114 ui.stack([attribute.style(styles)], [view_navbar(model), page]) ··· 116 122 117 123 const navitem_style: List(#(String, String)) = [ 118 124 #("text-decoration", "none"), #("background-color", "#b8cfd2"), 119 - #("padding", "0.75em"), #("border-radius", "1em"), 120 - #("text-transform", "uppercase"), #("color", "black"), 125 + #("padding", "0.75em"), #("border-radius", "1em"), #("color", "black"), 121 126 ] 122 127 123 128 fn view_navbar(_) -> Element(Msg) { ··· 161 166 [ 162 167 cluster.of(html.div, [attribute.style(project_bar_style)], [ 163 168 html.img([attribute.src(project.img), attribute.style(icon_style)]), 164 - html.h1([], [common.link(project.title, "projects/" <> project.id)]), 169 + html.h1([], [ 170 + common.styled_link(project.title, "projects/" <> project.id), 171 + ]), 165 172 cluster.of( 166 173 html.div, 167 174 [attribute.style(project_bar_style)], ··· 185 192 186 193 fn view_project(model: Model, id: String) -> Element(Msg) { 187 194 html.h1([], [element.text("Project: " <> id)]) 195 + } 196 + 197 + const post_style: List(#(String, String)) = [ 198 + #("background-color", "#cae4e7"), #("border-radius", "1em"), 199 + #("padding", "1em"), #("margin-bottom", "1em"), 200 + ] 201 + 202 + fn day_to_string(day: Day) -> String { 203 + day.date |> int.to_string 204 + <> "/" 205 + <> day.month |> int.to_string 206 + <> "/" 207 + <> day.year |> int.to_string 188 208 } 189 209 190 210 fn view_posts(model: Model) -> Element(Msg) { 191 - html.h1([], [element.text("Posts")]) 211 + let posts = 212 + model.posts 213 + |> list.map(fn(post: posts.Post(Msg)) { 214 + ui.stack([attribute.style(post_style)], [ 215 + cluster.of( 216 + html.div, 217 + [ 218 + attribute.style([ 219 + #("display", "flex"), 220 + #("align-items", "center"), 221 + #("gap", "1em"), 222 + ]), 223 + ], 224 + [ 225 + html.h1([], [common.styled_link(post.title, "posts/" <> post.id)]), 226 + html.p([attribute.style([#("color", "gray")])], [ 227 + element.text("Author: " <> post.author), 228 + ]), 229 + html.p([attribute.style([#("color", "gray")])], [ 230 + element.text("Date Posted: " <> post.date_posted |> day_to_string), 231 + ]), 232 + ], 233 + ), 234 + html.p([], [post.summary]), 235 + ]) 236 + }) 237 + html.div([], posts) 238 + } 239 + 240 + fn view_post(model: Model, id: String) -> Element(Msg) { 241 + html.h1([], [element.text("Post: " <> id)]) 192 242 }
+6 -2
src/website/common.gleam
··· 3 3 import lustre/element/html 4 4 5 5 const link_style: List(#(String, String)) = [ 6 - #("text-decoration", "none"), #("color", "black"), 6 + #("text-decoration", "underline"), #("color", "black"), 7 7 ] 8 8 9 - pub fn link(text: String, link: String) -> element.Element(a) { 9 + pub fn styled_link(text: String, link: String) -> element.Element(a) { 10 10 html.a([attr.href(link), attr.style(link_style)], [element.text(text)]) 11 11 } 12 + 13 + pub fn link(text: String, link: String) -> element.Element(a) { 14 + html.a([attr.href(link)], [element.text(text)]) 15 + }
+8 -8
src/website/posts.gleam
··· 3 3 import lustre/element/html 4 4 import website/common.{link} 5 5 6 - pub type Post { 6 + pub type Post(a) { 7 7 Post( 8 8 id: String, 9 9 title: String, 10 10 author: String, 11 11 date_posted: Day, 12 - summary: element.Element(String), 13 - content: element.Element(String), 12 + summary: element.Element(a), 13 + content: element.Element(a), 14 14 ) 15 15 } 16 16 17 - pub fn all() -> List(Post) { 18 - [release_mystcraft_ages(), mystcraft_ages_alpha_2()] 17 + pub fn all() -> List(Post(a)) { 18 + [mystcraft_ages_alpha_2(), release_mystcraft_ages()] 19 19 } 20 20 21 - fn mystcraft_short_descriptor() -> element.Element(String) { 21 + fn mystcraft_short_descriptor() -> element.Element(a) { 22 22 html.p([], [ 23 23 element.text("A modern reimagining of the original "), 24 24 link("Mystcraft", "https://www.curseforge.com/minecraft/mc-mods/mystcraft"), ··· 26 26 ]) 27 27 } 28 28 29 - fn release_mystcraft_ages() -> Post { 29 + fn release_mystcraft_ages() -> Post(a) { 30 30 Post( 31 31 id: "mystcraft-ages-alpha-1", 32 32 title: "Mystcraft: Ages", ··· 90 90 ) 91 91 } 92 92 93 - fn mystcraft_ages_alpha_2() -> Post { 93 + fn mystcraft_ages_alpha_2() -> Post(a) { 94 94 Post( 95 95 id: "mystcraft-ages-alpha-2", 96 96 title: "UPDATE: Mystcraft: Ages",