@@ -3,6 +3,7 @@ import lustre/attribute
33import lustre/element . { type Element }
44import lustre/element/html
55import website/component
6+ import website/data/blog
67
78fn index ( ) {
89 component . text_page ( "Hello and welcome to my website!" , [
@@ -55,20 +56,45 @@ fn index() {
5556 ] )
5657}
5758
58- pub fn view ( ) -> Element ( a ) {
59- component . page ( "Home" , [ index ( ) , my_stuff ( ) ] )
59+ pub fn view ( posts : List ( blog . Post ( _ ) ) ) -> Element ( _ ) {
60+ component . page ( "Home" , [ index ( ) , my_stuff ( posts ) ] )
6061}
6162
62- pub fn my_stuff ( ) {
63- component . text_page ( "My Stuff" , [
64- html . h2 ( [ attribute . class ( "text-2xl font-bold leading-tight my-2" ) ] , [
65- element . text ( "Links" ) ,
66- ] ) ,
67- html . p ( [ ] , list . map ( socials , social ) ) ,
68- html . h2 ( [ attribute . class ( "text-2xl font-bold leading-tight my-2" ) ] , [
69- element . text ( "Talks" ) ,
63+ pub fn my_stuff ( posts : List ( blog . Post ( _) ) ) -> component . Section ( _) {
64+ component . text_page (
65+ "My Stuff" ,
66+ list . flatten ( [
67+ [
68+ html . h2 ( [ attribute . class ( "text-2xl font-bold leading-tight my-2" ) ] , [
69+ element . text ( "Links" ) ,
70+ ] ) ,
71+ html . p ( [ ] , list . map ( socials , social ) ) ,
72+ html . h2 ( [ attribute . class ( "text-2xl font-bold leading-tight my-2" ) ] , [
73+ element . text ( "Posts" ) ,
74+ ] ) ,
75+ ] ,
76+ list . map ( posts , post ) ,
77+ [
78+ html . h2 ( [ attribute . class ( "text-2xl font-bold leading-tight my-2" ) ] , [
79+ element . text ( "Talks" ) ,
80+ ] ) ,
81+ ] ,
82+ list . map ( talks , talk ) ,
7083 ] ) ,
71- .. list . map ( talks , talk )
84+ )
85+ }
86+
87+ fn post ( post : blog . Post ( _) ) -> element . Element ( _) {
88+ html . div ( [ attribute . class ( "" ) ] , [
89+ html . a (
90+ [
91+ attribute . href ( "/blog/" <> post . slug ) ,
92+ attribute . class ( "text-xl font-bold hover:underline" ) ,
93+ ] ,
94+ [ html . text ( post . title ) ] ,
95+ ) ,
96+ html . p ( [ attribute . class ( "text-sm m-0" ) ] , [ element . text ( post . date ) ] ) ,
97+ html . p ( [ attribute . class ( "text-md my-0.5" ) ] , [ element . text ( post . description ) ] ) ,
7298 ] )
7399}
74100
0 commit comments