Pretty up the h-entry as a Bootstrap card
This commit is contained in:
parent
7cebf92356
commit
934457f671
3 changed files with 27 additions and 12 deletions
|
@ -5,10 +5,22 @@ module Widget.Entry ( entryR, hEntry ) where
|
|||
|
||||
import Import
|
||||
|
||||
import Data.Time.Format ( defaultTimeLocale, formatTime, iso8601DateFormat )
|
||||
import Data.Time.Format.Human ( humanReadableTime )
|
||||
|
||||
data FormattedTime = FormattedTime { timeUnfriendly :: String, timeFriendly :: String }
|
||||
|
||||
toFormattedTime :: MonadIO m => UTCTime -> m FormattedTime
|
||||
toFormattedTime time = FormattedTime (unfriendly time) <$> friendly time
|
||||
where unfriendly = formatTime defaultTimeLocale . iso8601DateFormat . Just $ "%H:%M:%S%z"
|
||||
friendly = liftIO . humanReadableTime
|
||||
|
||||
entryR :: Entity Entry -> Route App
|
||||
entryR (Entity entryId entry) = EntryR (entryKind entry) entryId (entrySlug entry)
|
||||
|
||||
hEntry :: Entity Entry -> Widget
|
||||
hEntry (Entity entryId entry) = do
|
||||
published <- toFormattedTime . entryPublished $ entry
|
||||
updated <- toFormattedTime . entryUpdated $ entry
|
||||
maybeAuthor <- handlerToWidget . runDB . get . entryAuthorId $ entry
|
||||
$(widgetFile "mf2/h-entry")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue