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