add rss 🎉
This commit is contained in:
parent
3ac457b1ec
commit
9284365c72
4 changed files with 70 additions and 12 deletions
|
@ -89,18 +89,29 @@ data PostInfo =
|
|||
instance YAML.ToYAML PostInfo where
|
||||
toYAML (Info file title date tags summary) = YAML.obj
|
||||
[("date" ##= date),
|
||||
("date-rss" ##= toRss date),
|
||||
("title" ##= title),
|
||||
("tags" ##= tags),
|
||||
("file" ##= Text.pack (fixup file)),
|
||||
("summary" ##= summary)]
|
||||
where fixup f = Path.replaceExtension f "html"
|
||||
where
|
||||
fixup f = Path.replaceExtension f "html"
|
||||
toRss (BD d) = RD d
|
||||
|
||||
newtype BlogDate = D Day deriving (Eq, Ord)
|
||||
newtype BlogDate = BD Day deriving (Eq, Ord)
|
||||
newtype RssDate = RD Day deriving (Eq, Ord)
|
||||
|
||||
instance YAML.FromYAML RssDate where
|
||||
parseYAML = YAML.withStr "YYYY-MM-DD" $
|
||||
fmap RD . parseTimeM True defaultTimeLocale "%F" . Text.unpack
|
||||
|
||||
instance YAML.ToYAML RssDate where
|
||||
toYAML (RD d) = YAML.str $ Text.pack $
|
||||
formatTime defaultTimeLocale "%a, %d %b %Y 00:00:01 UT" d
|
||||
|
||||
instance YAML.FromYAML BlogDate where
|
||||
parseYAML = YAML.withStr "YYYY-MM-DD" $
|
||||
fmap D . parseTimeM True defaultTimeLocale "%F" . Text.unpack
|
||||
parseYAML = fmap (\(RD d) -> BD d) . YAML.parseYAML
|
||||
|
||||
instance YAML.ToYAML BlogDate where
|
||||
toYAML (D d) = YAML.str $ Text.pack $ map toLower $
|
||||
toYAML (BD d) = YAML.str $ Text.pack $ map toLower $
|
||||
formatTime defaultTimeLocale "%a %-d %B %Y" d
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue