Added post + project overview to homepage

Signed-off-by: Naomi Roberts <mia@naomieow.xyz>

lesbian.skin 14a035fc 31188f8a

verified
+5 -1
src/build.gleam
··· 24 24 25 25 let build = 26 26 ssg.new("./priv") 27 - |> ssg.add_static_route("/", index.view() |> common.wrapper("Home", _)) 27 + |> ssg.add_static_route( 28 + "/", 29 + index.view(posts: posts.all(), projects: projects.all()) 30 + |> common.wrapper("Home", _), 31 + ) 28 32 |> ssg.add_static_route( 29 33 "/projects", 30 34 project.view_all(projects.all()) |> common.wrapper("Projects", _),
+2 -2
src/website/common.gleam
··· 13 13 title: String, 14 14 author: String, 15 15 date_posted: tom.Date, 16 - summary: element.Element(a), 16 + summary: String, 17 17 content: element.Element(a), 18 18 ) 19 19 } ··· 30 30 img: String, 31 31 links: List(Link), 32 32 archived: Bool, 33 - summary: element.Element(a), 33 + summary: String, 34 34 content: element.Element(a), 35 35 ) 36 36 }
+1 -1
src/website/data/posts.gleam
··· 27 27 title:, 28 28 author:, 29 29 date_posted:, 30 - summary: html.p([], summary |> djot.render(djot.default_renderer())), 30 + summary: summary, 31 31 content: html.div( 32 32 [], 33 33 post_md
+1 -1
src/website/data/projects.gleam
··· 50 50 |> string.replace(" ", "-"), 51 51 img:, 52 52 links:, 53 - summary: html.p([], summary |> djot.render(djot.default_renderer())), 53 + summary: summary, 54 54 title:, 55 55 content: html.div( 56 56 [],
+100 -1
src/website/page/index.gleam
··· 1 + import gleam/list 1 2 import lustre/attribute as attr 2 3 import lustre/element.{type Element} 3 4 import lustre/element/html 4 5 import website/common 6 + import website/data/posts 5 7 import website/style 6 8 7 - pub fn view() -> List(Element(a)) { 9 + pub fn view( 10 + posts posts: List(common.Post(a)), 11 + projects projects: List(common.Project(a)), 12 + ) -> List(Element(a)) { 13 + let post_count = list.length(posts) 14 + let project_count = list.length(projects) 8 15 [ 9 16 style.index_layout_query(), 10 17 html.div([attr.class("index-layout"), style.index_layout()], [ ··· 48 55 ), 49 56 ]), 50 57 ]), 58 + ]), 59 + html.div([], [ 60 + html.h1([attr.style("margin-bottom", "0")], [html.text("posts")]), 61 + common.link([], text: "view all", href: "/posts", external: False), 62 + html.span( 63 + [ 64 + attr.styles([ 65 + #("margin-top", "0.5em"), 66 + #("display", "flex"), 67 + #("gap", "1em"), 68 + #("flex-flow", "row wrap"), 69 + #("justify-content", "center"), 70 + ]), 71 + ], 72 + posts 73 + |> posts.sorted() 74 + |> list.drop(post_count - 2) 75 + |> list.reverse() 76 + |> list.map(fn(post) { 77 + html.a( 78 + [ 79 + style.post_card(), 80 + attr.style("max-width", "44%"), 81 + attr.href("/posts/" <> post.id), 82 + ], 83 + [ 84 + html.span( 85 + [ 86 + attr.styles([ 87 + #("display", "flex"), 88 + #("justify-content", "space-between"), 89 + ]), 90 + ], 91 + [ 92 + html.h4([attr.styles([#("margin", "0px")])], [ 93 + html.text(post.title), 94 + ]), 95 + html.h4([attr.styles([#("margin", "0px")])], [ 96 + html.text(post.date_posted |> common.date_to_string()), 97 + ]), 98 + ], 99 + ), 100 + html.text(post.summary), 101 + ], 102 + ) 103 + }), 104 + ), 105 + ]), 106 + html.div([], [ 107 + html.h1([attr.style("margin-bottom", "0")], [html.text("projects")]), 108 + common.link([], text: "view all", href: "/projects", external: False), 109 + html.span( 110 + [ 111 + attr.styles([ 112 + #("margin-top", "0.5em"), 113 + #("display", "flex"), 114 + #("gap", "1em"), 115 + #("flex-flow", "row wrap"), 116 + #("justify-content", "center"), 117 + ]), 118 + ], 119 + projects 120 + |> list.sample(2) 121 + |> list.map(fn(project) { 122 + html.a( 123 + [ 124 + style.post_card(), 125 + attr.style("max-width", "44%"), 126 + attr.href("/projects/" <> project.id), 127 + ], 128 + [ 129 + html.span( 130 + [ 131 + attr.styles([ 132 + #("display", "flex"), 133 + #("justify-content", "space-between"), 134 + ]), 135 + ], 136 + [ 137 + html.h4([attr.styles([#("margin", "0px")])], [ 138 + html.text(project.title), 139 + ]), 140 + html.h4([attr.styles([#("margin", "0px")])], [ 141 + html.text(project.author), 142 + ]), 143 + ], 144 + ), 145 + html.text(project.summary), 146 + ], 147 + ) 148 + }), 149 + ), 51 150 ]), 52 151 ] 53 152 }
+6 -2
src/website/page/post.gleam
··· 1 1 import gleam/list 2 2 import lustre/element.{type Element} 3 3 import lustre/element/html 4 + import lustre/ssg/djot 4 5 import website/common.{type Post} 5 6 import website/data/posts 6 7 import website/style ··· 30 31 ]), 31 32 ]), 32 33 ]), 33 - html.div([], [html.p([], [post.summary])]), 34 + html.div([], [ 35 + html.p([], post.summary |> djot.render(djot.default_renderer())), 36 + ]), 34 37 ]) 35 38 }) 36 39 } ··· 54 57 ]), 55 58 ]), 56 59 html.hr([]), 57 - html.div([], [post.content]), 60 + html.p([], post.summary |> djot.render(djot.default_renderer())), 61 + post.content, 58 62 ]), 59 63 ] 60 64 }
+5 -2
src/website/page/project.gleam
··· 2 2 import lustre/attribute as attr 3 3 import lustre/element.{type Element} 4 4 import lustre/element/html 5 + import lustre/ssg/djot 5 6 import website/common.{type Project, Project} 6 7 import website/data/projects 7 8 import website/style ··· 33 34 }), 34 35 ), 35 36 ]), 36 - html.div([], [html.p([], [project.summary])]), 37 + html.div([], [ 38 + html.p([], project.summary |> djot.render(djot.default_renderer())), 39 + ]), 37 40 ]) 38 41 }) 39 42 } ··· 61 64 }), 62 65 ), 63 66 ]), 64 - html.p([], [project.summary]), 67 + html.p([], project.summary |> djot.render(djot.default_renderer())), 65 68 project.content, 66 69 ]), 67 70 ]
+3
src/website/style.gleam
··· 126 126 #("border", "2px solid black"), 127 127 #("padding", "0.5em 1em 0.5em 1em"), 128 128 #("margin-bottom", "1em"), 129 + #("flex-grow", "1"), 130 + #("text-decoration", "none"), 131 + #("color", "black"), 129 132 ]) 130 133 } 131 134