-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRecentPosts.hs
More file actions
26 lines (22 loc) · 946 Bytes
/
RecentPosts.hs
File metadata and controls
26 lines (22 loc) · 946 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module RecentPosts where
import Data.Monoid
import qualified Data.Text.Lazy as T
import Types
recentPosts :: [Publish]
-> Int -- Amount of recent posts to get
-> T.Text
recentPosts p i = outputRecent . mconcat . map formatRecent $ recent
where
recent = take i p
outputRecent x = mconcat [ T.pack "<div class=\"recent\"><div class=\"recentHeader\">Recent Posts:</div><div class=\"recentContent\"><ul>"
, x
, T.pack "</ul></div></div>"
]
formatRecent x = mconcat [ T.pack "<li>"
, T.pack "<a href=\""
, T.pack $ _publishedURL x
, T.pack "\">"
, title x
, T.pack "</a>"
, T.pack "</li>" ]
title x = _title . _post $ x