From 7023da3902a4bec17d5f21643eb4be4909644ee8 Mon Sep 17 00:00:00 2001 From: rhiannon morris Date: Sun, 15 Sep 2024 17:46:06 +0200 Subject: [PATCH] add post summaries --- blog-meta/post-lists.hs | 29 ++++++++++++++++------------- style/page.css | 17 +++++++++++++++++ templates/postlist.html | 9 ++++++--- 3 files changed, 39 insertions(+), 16 deletions(-) diff --git a/blog-meta/post-lists.hs b/blog-meta/post-lists.hs index 2fb365e..0919577 100644 --- a/blog-meta/post-lists.hs +++ b/blog-meta/post-lists.hs @@ -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 .: "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 - [("date" ##= date), - ("title" ##= title), - ("tags" ##= tags), - ("file" ##= Text.pack (fixup file))] + toYAML (Info file title date tags summary) = YAML.obj + [("date" ##= date), + ("title" ##= title), + ("tags" ##= tags), + ("file" ##= Text.pack (fixup file)), + ("summary" ##= summary)] where fixup f = Path.replaceExtension f "html" newtype BlogDate = D Day deriving (Eq, Ord) diff --git a/style/page.css b/style/page.css index 9d53405..273113e 100644 --- a/style/page.css +++ b/style/page.css @@ -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; } diff --git a/templates/postlist.html b/templates/postlist.html index 5c57498..7e87b93 100644 --- a/templates/postlist.html +++ b/templates/postlist.html @@ -1,9 +1,12 @@
- +