Make entry names optional, since notes shouldn't have names and articles should
This commit is contained in:
parent
10b1ed834a
commit
fa992bc861
6 changed files with 24 additions and 5 deletions
15
src/Model/Entry.hs
Normal file
15
src/Model/Entry.hs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{-# 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue