add post summaries
This commit is contained in:
parent
3ae0cd7c52
commit
7023da3902
3 changed files with 39 additions and 16 deletions
|
@ -8,7 +8,7 @@ import qualified Data.Text as Text
|
|||
import Data.Time
|
||||
import Misc
|
||||
import qualified YAML
|
||||
import YAML ((.:), (.!=), (##=))
|
||||
import YAML ((.:), (.:?), (.!=), (##=))
|
||||
import qualified System.Console.GetOpt as GetOpt
|
||||
import qualified System.FilePath.Find as Find
|
||||
import qualified System.FilePath as Path
|
||||
|
@ -69,27 +69,30 @@ getInfo dir file = do
|
|||
let dirs = Path.splitPath dir
|
||||
let file' = Path.joinPath $ drop (length dirs) $ Path.splitPath file
|
||||
unwrap file $ YAML.parseEither $
|
||||
yaml & YAML.withMap "title, date, tags" \m ->
|
||||
yaml & YAML.withMap "title, date, tags, summary?" \m ->
|
||||
Info <$> pure file'
|
||||
<*> m .: "title"
|
||||
<*> m .: "date"
|
||||
<*> m .: "tags" .!= []
|
||||
<*> m .:? "summary"
|
||||
|
||||
-- | the front matter info we care about
|
||||
data PostInfo =
|
||||
Info {
|
||||
_nfoFile :: FilePath,
|
||||
_nfoTitle :: Text,
|
||||
infoFile :: FilePath,
|
||||
infoTitle :: Text,
|
||||
infoDate :: BlogDate,
|
||||
infoTags :: [Text]
|
||||
infoTags :: [Text],
|
||||
infoSummary :: Maybe Text
|
||||
}
|
||||
|
||||
instance YAML.ToYAML PostInfo where
|
||||
toYAML (Info file title date tags) = YAML.obj
|
||||
toYAML (Info file title date tags summary) = YAML.obj
|
||||
[("date" ##= date),
|
||||
("title" ##= title),
|
||||
("tags" ##= tags),
|
||||
("file" ##= Text.pack (fixup file))]
|
||||
("file" ##= Text.pack (fixup file)),
|
||||
("summary" ##= summary)]
|
||||
where fixup f = Path.replaceExtension f "html"
|
||||
|
||||
newtype BlogDate = D Day deriving (Eq, Ord)
|
||||
|
|
|
@ -133,7 +133,24 @@ header .date {
|
|||
|
||||
.post-list .date, .tag-list .count {
|
||||
font-size: 85%;
|
||||
}
|
||||
|
||||
.post-list li + li {
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
|
||||
.post-desc {
|
||||
margin: 0;
|
||||
font-size: small;
|
||||
font-style: italic;
|
||||
line-height: 125%;
|
||||
}
|
||||
|
||||
.post-desc p {
|
||||
margin: 0;
|
||||
}
|
||||
.post-desc p + p {
|
||||
margin-top: .5em;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
<main>
|
||||
<ul class=post-list>
|
||||
<menu class=post-list>
|
||||
$for(posts)$
|
||||
<li>
|
||||
<a href=$it.file$>$it.title$</a>
|
||||
<a href='$it.file$' class=post-link>$it.title$</a>
|
||||
<span class=date>($it.date$)</span>
|
||||
$if(it.summary)$
|
||||
<div class=post-desc>$it.summary$</div>
|
||||
$endif$
|
||||
$endfor$
|
||||
</ul>
|
||||
</menu>
|
||||
</main>
|
||||
|
|
Loading…
Reference in a new issue