Add permalinks to h-entries

This commit is contained in:
Danielle McLean 2017-10-09 09:02:42 +11:00
parent 9679234062
commit 7cebf92356
Signed by: 00dani
GPG key ID: 5A5D2D1AFF12EEC5
3 changed files with 8 additions and 7 deletions

View file

@ -7,7 +7,7 @@ import Import
import Web.Slug ( Slug )
import qualified Entry.Kind as K
import Widget.Entry ( hEntry )
import Widget.Entry ( entryR, hEntry )
import Widget.Feed ( hFeed )
getEntriesR :: K.EntryKind -> Handler Html
@ -15,9 +15,6 @@ getEntriesR kind = do
entries <- runDB $ selectList [EntryKind ==. kind] [Desc EntryPublished]
defaultLayout $(widgetFile "entries")
entryR :: Entity Entry -> Route App
entryR (Entity entryId entry) = EntryR (entryKind entry) entryId (entrySlug entry)
checkMatching :: K.EntryKind -> Slug -> Entry -> Bool
checkMatching kind slug entry = (kind == entryKind entry) && (slug == entrySlug entry)

View file

@ -1,10 +1,13 @@
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
module Widget.Entry ( hEntry ) where
module Widget.Entry ( entryR, hEntry ) where
import Import
entryR :: Entity Entry -> Route App
entryR (Entity entryId entry) = EntryR (entryKind entry) entryId (entrySlug entry)
hEntry :: Entity Entry -> Widget
hEntry (Entity entryId entry) = do
maybeAuthor <- handlerToWidget . runDB . get . entryAuthorId $ entry

View file

@ -1,7 +1,8 @@
<article .h-entry>
<h1 .p-name>#{entryName entry}
<a .u-url href="@{entryR (Entity entryId entry)}">permalink
<p>
Published
published
$maybe author <- maybeAuthor
\ by
<a .p-author.h-card href=@{HomeR}>