16 lines
405 B
Haskell
16 lines
405 B
Haskell
|
{-# LANGUAGE OverloadedStrings #-}
|
||
|
module Model.Entry where
|
||
|
|
||
|
import Model ( Entry, entryName, entryContent )
|
||
|
import Data.Maybe ( fromMaybe )
|
||
|
|
||
|
import qualified Data.Text as T
|
||
|
|
||
|
entryTitle :: Entry -> T.Text
|
||
|
entryTitle = fromMaybe <$> shorten 30 . entryContent <*> entryName
|
||
|
|
||
|
shorten :: Int -> T.Text -> T.Text
|
||
|
shorten n t
|
||
|
| T.length t > n = flip T.append "..." . T.take (n - 1) $ t
|
||
|
| otherwise = t
|