Skip to content

Commit d3c27b3

Browse files
authored
Docker blogpost (#139)
* cleanup homepage, add blog link * show posts on homepage * add content * position relative for the anchor * harders * footer * more cleanup
1 parent 6d96518 commit d3c27b3

File tree

9 files changed

+306
-157
lines changed

9 files changed

+306
-157
lines changed

app/Route/Blog.elm

Lines changed: 4 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,15 @@ module Route.Blog exposing (Model, Msg, route, Data, ActionData)
88

99
import Article
1010
import BackendTask exposing (BackendTask)
11-
import Colours
1211
import Css exposing (..)
13-
import Date exposing (Date)
14-
import Effect
15-
import ErrorPage
1612
import FatalError exposing (FatalError)
1713
import Head
1814
import Head.Seo as Seo
19-
import Html as HtmlOriginal
20-
import Html.Styled as Html exposing (Html, styled)
21-
import Html.Styled.Attributes exposing (css, fromUnstyled)
15+
import Html.Styled as Html exposing (Html)
16+
import Html.Styled.Attributes exposing (css)
2217
import Pages.Url
23-
import PagesMsg
2418
import Route exposing (Route)
2519
import RouteBuilder exposing (App, StatelessRoute)
26-
import Server.Request
27-
import Server.Response
2820
import Shared
2921
import UrlPath
3022
import Util
@@ -55,7 +47,7 @@ route =
5547

5648

5749
type alias Data =
58-
List ( Route, Article.ArticleMetadata )
50+
List ( Route, Article.Metadata )
5951

6052

6153
type alias ActionData =
@@ -122,57 +114,5 @@ content articles =
122114
, property "gap" "1em"
123115
]
124116
]
125-
<|
126-
List.map viewBlogPost articles
117+
(List.map Article.view articles)
127118
]
128-
129-
130-
viewBlogPost : ( Route, Article.ArticleMetadata ) -> Html msg
131-
viewBlogPost ( route_, metadata ) =
132-
Html.div
133-
[ css
134-
[ Util.flexDirection Util.Column
135-
, width (pct 100)
136-
, padding (em 1.5)
137-
, border3 (px 1) solid (Colours.toCss Colours.gray)
138-
, borderRadius (em 0.5)
139-
, hover
140-
[ borderColor (Colours.toCss Colours.black) ]
141-
, property "gap" "0.5em"
142-
]
143-
]
144-
[ Route.toLink (blogPostTitle metadata) route_
145-
, blogDate metadata.published
146-
, blogDescription metadata.description
147-
]
148-
149-
150-
blogPostTitle : Article.ArticleMetadata -> List (HtmlOriginal.Attribute msg) -> Html msg
151-
blogPostTitle metadata attrs =
152-
Html.a
153-
([ css
154-
[ fontSize (em 1.25)
155-
, fontWeight bold
156-
, textDecoration none
157-
, color (Colours.toCss Colours.black)
158-
, hover
159-
[ color (Colours.toCss Colours.themeBlue) ]
160-
]
161-
]
162-
++ List.map fromUnstyled attrs
163-
)
164-
[ Html.text metadata.title ]
165-
166-
167-
blogDate : Date -> Html msg
168-
blogDate date =
169-
Html.p
170-
[ css
171-
[ fontSize (em 0.75) ]
172-
]
173-
[ Html.text <| Date.format "MMMM d, yyyy" date ]
174-
175-
176-
blogDescription : String -> Html msg
177-
blogDescription description =
178-
Html.p [] [ Html.text description ]

app/Route/Blog/Slug_.elm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
port module Route.Blog.Slug_ exposing (ActionData, Data, Model, Msg, route)
22

3-
import Article exposing (ArticleMetadata)
3+
import Article exposing (Metadata)
44
import BackendTask exposing (BackendTask)
55
import Css exposing (..)
66
import Date exposing (Date)
@@ -60,7 +60,7 @@ pages =
6060

6161

6262
type alias Data =
63-
{ metadata : ArticleMetadata
63+
{ metadata : Metadata
6464
, body : List Markdown.Block.Block
6565
}
6666

app/Route/Index.elm

Lines changed: 57 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module Route.Index exposing (ActionData, Data, Model, Msg, footer, route)
22

3+
import Article
34
import BackendTask exposing (BackendTask)
45
import BackendTask.File
56
import Colours
@@ -9,9 +10,8 @@ import FatalError exposing (FatalError)
910
import FeatherIcons
1011
import Head
1112
import Head.Seo as Seo
12-
import Html.Styled as Html exposing (Attribute, Html, styled)
13-
import Html.Styled.Attributes exposing (css, media)
14-
import Html.Styled.Events exposing (onClick)
13+
import Html.Styled as Html exposing (Html)
14+
import Html.Styled.Attributes exposing (css)
1515
import Icon
1616
import Icosahedron
1717
import Pages.Url
@@ -40,6 +40,12 @@ type alias RouteParams =
4040

4141

4242
type alias Data =
43+
{ projects : ProjectData
44+
, blogPosts : BlogData
45+
}
46+
47+
48+
type alias ProjectData =
4349
{ -- top 3 "pinned" projects
4450
pinnedProjects : List Project
4551

@@ -48,6 +54,10 @@ type alias Data =
4854
}
4955

5056

57+
type alias BlogData =
58+
List ( Route.Route, Article.Metadata )
59+
60+
5161
type alias ActionData =
5262
{}
5363

@@ -110,6 +120,13 @@ subscriptions routeParams path shared model =
110120

111121
data : BackendTask FatalError Data
112122
data =
123+
BackendTask.succeed Data
124+
|> BackendTask.andMap getProjects
125+
|> BackendTask.andMap getBlogPosts
126+
127+
128+
getProjects : BackendTask FatalError ProjectData
129+
getProjects =
113130
BackendTask.File.rawFile "projects.yml"
114131
|> BackendTask.allowFatal
115132
|> BackendTask.andThen Project.getProjects
@@ -118,6 +135,13 @@ data =
118135
(\data_ -> { pinnedProjects = data_.featured, homeProjects = data_.home })
119136

120137

138+
getBlogPosts : BackendTask FatalError BlogData
139+
getBlogPosts =
140+
Article.allMetadata
141+
|> BackendTask.allowFatal
142+
|> BackendTask.map (List.take 3)
143+
144+
121145
head :
122146
App Data ActionData RouteParams
123147
-> List Head.Tag
@@ -194,10 +218,8 @@ view app shared model =
194218
, property "gap" "4em"
195219
]
196220
]
197-
[ about
198-
, projects app.data
199-
200-
-- , blog
221+
[ blog app.data.blogPosts
222+
, projects app.data.projects
201223
, footer
202224
]
203225
]
@@ -236,7 +258,7 @@ jumbotron =
236258
, fontSize (px 25)
237259
]
238260
]
239-
[ Html.text "Welcome to my website! I am a CS Student at the University of Alberta. I enjoy making webapps, primarily with React and Elm, and I'm also a big Docker + DevOps fan." ]
261+
[ Html.text "Welcome to my website! I'm a software engineer currently at InEight. I enjoy making webapps, primarily with React and Elm, and I'm also a big Docker + DevOps fan. I hope you enjoy your time here!" ]
240262
, jumbotronNavbar
241263
, Icon.view
242264
[ css [ displayFlex, flexDirection column, alignItems center ] ]
@@ -290,10 +312,8 @@ jumbotronNavbar : Html msg
290312
jumbotronNavbar =
291313
let
292314
navItems =
293-
[ ( "About", "#about", False )
315+
[ ( "Blog", "#blog", False )
294316
, ( "Projects", "#projects", False )
295-
296-
-- , ( "Blog", "#blog", False )
297317
, ( "Resume", "https://joshuaji.com/resume/Joshua%20Ji%20Resume.pdf", True )
298318
]
299319
in
@@ -341,47 +361,49 @@ icosahedron model =
341361

342362

343363

344-
---- ABOUT
364+
---- BLOG
345365

346366

347-
about : Html msg
348-
about =
349-
let
350-
textBlock =
351-
styled Html.p
352-
[ fontSize (em 1.3) ]
353-
in
367+
blog : BlogData -> Html msg
368+
blog data_ =
354369
Html.div
355370
[ css
356371
[ Util.flexDirection Util.Column
357372
, property "gap" "2em"
358373
]
359374
]
360-
[ Util.linkedHeader "about" "About"
361-
, textBlock [] [ Html.text "I started off with HTML, CSS and Javascript: making blogs, web apps, or anything that seemed cool to me." ]
362-
, textBlock []
363-
[ Html.text "Currently, I use "
364-
, Util.textLink "https://elm-lang.org/" "Elm"
365-
, Html.text " and Typescript for most of my projects, and I'm learning Haskell, Purescript and Rust on my free time."
375+
[ Util.linkedHeader "blog" "Blog"
376+
, Html.h2 [] [ Html.text "📅 Recent Posts" ]
377+
, recentPosts data_
378+
, Html.div
379+
[ css
380+
[ Util.flexDirection Util.Row
381+
, alignItems center
382+
, fontSize (em 1.25)
383+
]
366384
]
367-
, textBlock []
368-
[ Html.text "I've recently been taking a deep dive into DevOps. I've recently interned at "
369-
, Util.textLink "https://www.nanosticsdx.com/" "Nanostics"
370-
, Html.text " where I worked on deploying and maintaining a ML model on Azure, as well as creating a webapp interface for it."
385+
[ Util.textRouteLink Route.Blog "All posts"
386+
, Icon.view [] { icon = FeatherIcons.chevronRight, strokeWidth = 2, size = 20, msg = Nothing }
371387
]
372-
, textBlock []
373-
[ Html.text "In my free time, I like to play volleyball and walk my dog. I always try to find time to read, check me out on "
374-
, Util.textLink "https://hardcover.app/@OshuaJay" "Hardcover"
375-
, Html.text "!"
388+
]
389+
390+
391+
recentPosts : BlogData -> Html msg
392+
recentPosts data_ =
393+
Html.div
394+
[ css
395+
[ Util.flexDirection Util.Column
396+
, property "gap" "1em"
376397
]
377398
]
399+
(List.map Article.view data_)
378400

379401

380402

381403
---- PROJECTS
382404

383405

384-
projects : Data -> Html msg
406+
projects : ProjectData -> Html msg
385407
projects data_ =
386408
Html.div
387409
[ css
@@ -399,7 +421,7 @@ projects data_ =
399421
, fontSize (em 1.25)
400422
]
401423
]
402-
[ Util.textRouteLink Route.AllProjects "See more projects"
424+
[ Util.textRouteLink Route.AllProjects "More projects"
403425
, Icon.view [] { icon = FeatherIcons.chevronRight, strokeWidth = 2, size = 20, msg = Nothing }
404426
]
405427

@@ -419,38 +441,6 @@ featuredProjects projs =
419441
(List.map Project.viewFeatured projs)
420442

421443

422-
homeProjects : List Project -> Html msg
423-
homeProjects projs =
424-
Html.div
425-
[ css
426-
[ Util.flexDirection Util.Column
427-
, alignItems center
428-
, justifyContent center
429-
, property "gap" "0.75em"
430-
]
431-
]
432-
(List.map Project.view projs)
433-
434-
435-
436-
---- BLOG
437-
438-
439-
blog : Html msg
440-
blog =
441-
Html.div
442-
[ css
443-
[ Util.flexDirection Util.Column
444-
, property "gap" "2em"
445-
]
446-
]
447-
[ Util.linkedHeader "blog" "Blog"
448-
, Html.h2 [] [ Html.text "Work in progress..." ]
449-
450-
-- , Html.h2 [] [ Html.text "📅 Recent Posts" ]
451-
]
452-
453-
454444

455445
---- FOOTER
456446

app/Shared.elm

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ import Colours
55
import Css exposing (..)
66
import Effect exposing (Effect)
77
import FatalError exposing (FatalError)
8+
import FeatherIcons
89
import Html
910
import Html.Styled
1011
import Html.Styled.Attributes exposing (css)
12+
import Icon
1113
import Icosahedron
1214
import Pages.Flags
1315
import Pages.PageUrl exposing (PageUrl)
1416
import Route exposing (Route)
1517
import SharedTemplate exposing (SharedTemplate)
16-
import Url
1718
import UrlPath exposing (UrlPath)
1819
import Util
1920
import View exposing (View)
@@ -131,6 +132,7 @@ withNavbarTemplate : Model -> (Msg -> msg) -> List (Html.Styled.Html msg) -> Lis
131132
withNavbarTemplate model toMsg content =
132133
[ Html.Styled.map toMsg (navbar model)
133134
, Html.Styled.main_ [] content
135+
, Html.Styled.map toMsg footer
134136
]
135137

136138

@@ -161,4 +163,32 @@ navbar model =
161163
, Html.Styled.li
162164
[]
163165
[ Util.textRouteLink Route.AllProjects "Projects" ]
166+
, Html.Styled.li
167+
[]
168+
[ Util.textRouteLink Route.Blog "Blog" ]
169+
]
170+
171+
172+
footer : Html.Styled.Html Msg
173+
footer =
174+
Html.Styled.div
175+
[ css
176+
[ Util.flexDirection Util.Row
177+
, property "gap" "0.5em"
178+
, margin2 (em 2.5) (em 2)
179+
]
180+
]
181+
[ Html.Styled.p
182+
[ css [ flex (int 1) ] ]
183+
[ Html.Styled.text "© 2025 Joshua Ji"
184+
]
185+
, Html.Styled.a
186+
[ Html.Styled.Attributes.href "https://github.com/joshuanianji/" ]
187+
[ Icon.view []
188+
{ icon = FeatherIcons.github
189+
, strokeWidth = 2
190+
, size = 16
191+
, msg = Nothing
192+
}
193+
]
164194
]

0 commit comments

Comments
 (0)