Add permalinks to h-entries
This commit is contained in:
parent
9679234062
commit
7cebf92356
3 changed files with 8 additions and 7 deletions
|
@ -7,7 +7,7 @@ import Import
|
||||||
import Web.Slug ( Slug )
|
import Web.Slug ( Slug )
|
||||||
|
|
||||||
import qualified Entry.Kind as K
|
import qualified Entry.Kind as K
|
||||||
import Widget.Entry ( hEntry )
|
import Widget.Entry ( entryR, hEntry )
|
||||||
import Widget.Feed ( hFeed )
|
import Widget.Feed ( hFeed )
|
||||||
|
|
||||||
getEntriesR :: K.EntryKind -> Handler Html
|
getEntriesR :: K.EntryKind -> Handler Html
|
||||||
|
@ -15,9 +15,6 @@ getEntriesR kind = do
|
||||||
entries <- runDB $ selectList [EntryKind ==. kind] [Desc EntryPublished]
|
entries <- runDB $ selectList [EntryKind ==. kind] [Desc EntryPublished]
|
||||||
defaultLayout $(widgetFile "entries")
|
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 :: K.EntryKind -> Slug -> Entry -> Bool
|
||||||
checkMatching kind slug entry = (kind == entryKind entry) && (slug == entrySlug entry)
|
checkMatching kind slug entry = (kind == entryKind entry) && (slug == entrySlug entry)
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
{-# LANGUAGE NoImplicitPrelude #-}
|
{-# LANGUAGE NoImplicitPrelude #-}
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
{-# LANGUAGE TemplateHaskell #-}
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
module Widget.Entry ( hEntry ) where
|
module Widget.Entry ( entryR, hEntry ) where
|
||||||
|
|
||||||
import Import
|
import Import
|
||||||
|
|
||||||
|
entryR :: Entity Entry -> Route App
|
||||||
|
entryR (Entity entryId entry) = EntryR (entryKind entry) entryId (entrySlug entry)
|
||||||
|
|
||||||
hEntry :: Entity Entry -> Widget
|
hEntry :: Entity Entry -> Widget
|
||||||
hEntry (Entity entryId entry) = do
|
hEntry (Entity entryId entry) = do
|
||||||
maybeAuthor <- handlerToWidget . runDB . get . entryAuthorId $ entry
|
maybeAuthor <- handlerToWidget . runDB . get . entryAuthorId $ entry
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
<article .h-entry>
|
<article .h-entry>
|
||||||
<h1.p-name>#{entryName entry}
|
<h1 .p-name>#{entryName entry}
|
||||||
|
<a .u-url href="@{entryR (Entity entryId entry)}">permalink
|
||||||
<p>
|
<p>
|
||||||
Published
|
published
|
||||||
$maybe author <- maybeAuthor
|
$maybe author <- maybeAuthor
|
||||||
\ by
|
\ by
|
||||||
<a .p-author.h-card href=@{HomeR}>
|
<a .p-author.h-card href=@{HomeR}>
|
||||||
|
|
Loading…
Reference in a new issue