Render entryContent as Markdown too :3
This commit is contained in:
parent
805e422eba
commit
e24e7db641
3 changed files with 21 additions and 6 deletions
|
@ -28,7 +28,7 @@ Profile
|
||||||
Entry
|
Entry
|
||||||
kind EntryKind maxlen=255
|
kind EntryKind maxlen=255
|
||||||
name Text Maybe maxlen=255
|
name Text Maybe maxlen=255
|
||||||
content Text sqltype=longtext
|
content Markdown sqltype=longtext
|
||||||
published UTCTime
|
published UTCTime
|
||||||
updated UTCTime
|
updated UTCTime
|
||||||
authorId UserId
|
authorId UserId
|
||||||
|
|
|
@ -2,14 +2,27 @@
|
||||||
module Model.Entry where
|
module Model.Entry where
|
||||||
|
|
||||||
import Model ( Entry, entryName, entryContent )
|
import Model ( Entry, entryName, entryContent )
|
||||||
|
import Model.Markdown ( Markdown(Markdown), unMarkdown )
|
||||||
import Data.Maybe ( fromMaybe )
|
import Data.Maybe ( fromMaybe )
|
||||||
|
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
|
import qualified Data.Text.Lazy as TL
|
||||||
|
|
||||||
entryTitle :: Entry -> T.Text
|
entryTitle :: Entry -> T.Text
|
||||||
entryTitle = fromMaybe <$> shorten 30 . entryContent <*> entryName
|
entryTitle = fromMaybe <$> TL.toStrict . shorten 30 . unMarkdown . entryContent <*> entryName
|
||||||
|
|
||||||
shorten :: Int -> T.Text -> T.Text
|
class Shorten a where
|
||||||
shorten n t
|
shorten :: Integral n => n -> a -> a
|
||||||
| T.length t > n = flip T.append "..." . T.take (n - 1) $ t
|
|
||||||
| otherwise = t
|
instance Shorten T.Text where
|
||||||
|
shorten n t
|
||||||
|
| T.length t > fromIntegral n = flip T.append "..." . T.take (fromIntegral n - 1) $ t
|
||||||
|
| otherwise = t
|
||||||
|
|
||||||
|
instance Shorten TL.Text where
|
||||||
|
shorten n t
|
||||||
|
| TL.length t > fromIntegral n = flip TL.append "..." . TL.take (fromIntegral n - 1) $ t
|
||||||
|
| otherwise = t
|
||||||
|
|
||||||
|
instance Shorten Markdown where
|
||||||
|
shorten n (Markdown t) = Markdown $ shorten n t
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
article.h-entry
|
article.h-entry
|
||||||
|
.e-content p:last-child
|
||||||
|
margin-bottom: 0
|
||||||
> .card-footer
|
> .card-footer
|
||||||
display: flex
|
display: flex
|
||||||
flex-wrap: wrap
|
flex-wrap: wrap
|
||||||
|
|
Loading…
Reference in a new issue