summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbhinav Sarkar <abhinav.sarkar@gmail.com>2018-11-24 17:06:54 +0530
committerJasper Van der Jeugt <jaspervdj@gmail.com>2018-11-24 12:36:54 +0100
commitf3a17454fae3b140ada30ebef13f508179f4cd0d (patch)
treebb5e1ed0b3b92eb7a687e16f64b440ba7dddc473
parente2db1b21dde1dd0227670b6d84fab3b57411292e (diff)
downloadhakyll-f3a17454fae3b140ada30ebef13f508179f4cd0d.tar.gz
Adds render{Rss,Atom}WithTemmplates function in the Web.Feed module
-rw-r--r--lib/Hakyll/Web/Feed.hs38
1 files changed, 32 insertions, 6 deletions
diff --git a/lib/Hakyll/Web/Feed.hs b/lib/Hakyll/Web/Feed.hs
index 6e12146..531d653 100644
--- a/lib/Hakyll/Web/Feed.hs
+++ b/lib/Hakyll/Web/Feed.hs
@@ -22,6 +22,8 @@ module Hakyll.Web.Feed
( FeedConfiguration (..)
, renderRss
, renderAtom
+ , renderRssWithTemplates
+ , renderAtomWithTemplates
) where
@@ -126,14 +128,40 @@ renderFeed defFeed defItem config itemContext items = do
--------------------------------------------------------------------------------
+-- | Render an RSS feed using given templates with a number of items.
+renderRssWithTemplates ::
+ String -- ^ Feed template
+ -> String -- ^ Item template
+ -> FeedConfiguration -- ^ Feed configuration
+ -> Context String -- ^ Item context
+ -> [Item String] -- ^ Feed items
+ -> Compiler (Item String) -- ^ Resulting feed
+renderRssWithTemplates feedTemplate itemTemplate config context = renderFeed
+ feedTemplate itemTemplate config
+ (makeItemContext "%a, %d %b %Y %H:%M:%S UT" context)
+
+
+--------------------------------------------------------------------------------
+-- | Render an Atom feed using given templates with a number of items.
+renderAtomWithTemplates ::
+ String -- ^ Feed template
+ -> String -- ^ Item template
+ -> FeedConfiguration -- ^ Feed configuration
+ -> Context String -- ^ Item context
+ -> [Item String] -- ^ Feed items
+ -> Compiler (Item String) -- ^ Resulting feed
+renderAtomWithTemplates feedTemplate itemTemplate config context = renderFeed
+ feedTemplate itemTemplate config
+ (makeItemContext "%Y-%m-%dT%H:%M:%SZ" context)
+
+
+--------------------------------------------------------------------------------
-- | Render an RSS feed with a number of items.
renderRss :: FeedConfiguration -- ^ Feed configuration
-> Context String -- ^ Item context
-> [Item String] -- ^ Feed items
-> Compiler (Item String) -- ^ Resulting feed
-renderRss config context = renderFeed
- rssTemplate rssItemTemplate config
- (makeItemContext "%a, %d %b %Y %H:%M:%S UT" context)
+renderRss = renderRssWithTemplates rssTemplate rssItemTemplate
--------------------------------------------------------------------------------
@@ -142,9 +170,7 @@ renderAtom :: FeedConfiguration -- ^ Feed configuration
-> Context String -- ^ Item context
-> [Item String] -- ^ Feed items
-> Compiler (Item String) -- ^ Resulting feed
-renderAtom config context = renderFeed
- atomTemplate atomItemTemplate config
- (makeItemContext "%Y-%m-%dT%H:%M:%SZ" context)
+renderAtom = renderAtomWithTemplates atomTemplate atomItemTemplate
--------------------------------------------------------------------------------