summaryrefslogtreecommitdiff
path: root/src/Text/Hakyll
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Hakyll')
-rw-r--r--src/Text/Hakyll/Paginate.hs7
-rw-r--r--src/Text/Hakyll/Renderables.hs30
-rw-r--r--src/Text/Hakyll/Rss.hs13
3 files changed, 31 insertions, 19 deletions
diff --git a/src/Text/Hakyll/Paginate.hs b/src/Text/Hakyll/Paginate.hs
index 349360a..d4b1089 100644
--- a/src/Text/Hakyll/Paginate.hs
+++ b/src/Text/Hakyll/Paginate.hs
@@ -39,10 +39,15 @@ defaultPaginateConfiguration = PaginateConfiguration
-- The following metadata fields will be added:
--
-- - @$previous@: A link to the previous page.
+--
-- - @$next@: A link to the next page.
+--
-- - @$first@: A link to the first page.
+--
-- - @$last@: A link to the last page.
+--
-- - @$index@: 1-based index of the current page.
+--
-- - @$length@: Total number of pages.
--
-- When @$previous@ or @$next@ are not available, they will be just a label
@@ -72,7 +77,7 @@ paginate configuration renderables = paginate' Nothing renderables (1 :: Int)
, linkWithLabel lastLabel (last renderables) )
[] -> ( Left $ nextLabel configuration
, Left $ lastLabel configuration )
- customPage = createCustomPage "" []
+ customPage = createCustomPage ""
[ ("previous", previous)
, ("next", next)
, ("first", first)
diff --git a/src/Text/Hakyll/Renderables.hs b/src/Text/Hakyll/Renderables.hs
index 36fef09..4f320c6 100644
--- a/src/Text/Hakyll/Renderables.hs
+++ b/src/Text/Hakyll/Renderables.hs
@@ -26,11 +26,10 @@ import Text.Hakyll.Internal.Page
-- dependency checking. A @String@ is obviously more simple to use in some
-- cases.
createCustomPage :: String
- -> [FilePath]
-> [(String, Either String (RenderAction () String))]
-> Renderable
-createCustomPage url dependencies association = RenderAction
- { actionDependencies = dependencies ++ dataDependencies
+createCustomPage url association = RenderAction
+ { actionDependencies = dataDependencies
, actionUrl = Just $ return url
, actionFunction = \_ -> M.fromList <$> assoc'
}
@@ -50,13 +49,13 @@ createCustomPage url dependencies association = RenderAction
-- @CustomPage@.
--
-- > let customPage = createListingWith
--- > "index.html" -- Destination of the page.
--- > "templates/postitem.html" -- Path to template to
--- > -- render the items with.
--- > posts -- ^ Renderables to create the list with.
--- > [("title", "Home")] -- ^ Additional context
-createListing :: String -- ^ Destination of the page.
- -> FilePath -- ^ Template to render all items with.
+-- > "index.html" -- Destination of the page.
+-- > ["templates/postitem.html"] -- Paths to templates to render the
+-- > -- items with.
+-- > posts -- Renderables to create the list with.
+-- > [("title", Left "Home")] -- Additional context
+createListing :: String -- ^ Destination of the page.
+ -> [FilePath] -- ^ Templates to render all items with.
-> [Renderable] -- ^ Renderables in the list.
-> [(String, Either String (RenderAction () String))]
-> Renderable
@@ -67,17 +66,16 @@ createListing = createListingWith id
-- In addition to @createListing@, this function allows you to specify an
-- extra @ContextManipulation@ for all @Renderable@s given.
createListingWith :: ContextManipulation -- ^ Manipulation for the renderables.
- -> String -- ^ Destination of the page.
- -> FilePath -- ^ Template to render all items with.
+ -> String -- ^ Destination of the page.
+ -> [FilePath] -- ^ Templates to render all items with.
-> [Renderable] -- ^ Renderables in the list.
-> [(String, Either String (RenderAction () String))]
-> Renderable
-createListingWith manipulation url template renderables additional =
- createCustomPage url dependencies context
+createListingWith manipulation url templates renderables additional =
+ createCustomPage url context
where
- dependencies = template : concatMap actionDependencies renderables
context = ("body", Right concatenation) : additional
- concatenation = renderAndConcatWith manipulation [template] renderables
+ concatenation = renderAndConcatWith manipulation templates renderables
-- | Create a PagePath from a FilePath.
createPagePath :: FilePath -> Renderable
diff --git a/src/Text/Hakyll/Rss.hs b/src/Text/Hakyll/Rss.hs
index 025851b..5f1d867 100644
--- a/src/Text/Hakyll/Rss.hs
+++ b/src/Text/Hakyll/Rss.hs
@@ -39,8 +39,8 @@ createRssWith :: ContextManipulation -- ^ Manipulation to apply on the items.
createRssWith manipulation configuration renderables template itemTemplate =
listing >>> render template
where
- listing = createListingWith manipulation (rssUrl configuration) itemTemplate
- renderables additional
+ listing = createListingWith manipulation (rssUrl configuration)
+ [itemTemplate] renderables additional
additional = map (second $ Left . ($ configuration))
[ ("title", rssTitle)
@@ -48,6 +48,15 @@ createRssWith manipulation configuration renderables template itemTemplate =
]
-- | Render an RSS feed with a number of items.
+--
+-- Note that the @Renderable@s should have the following fields:
+--
+-- - @$title@: Title of the item.
+--
+-- - @$description@: Description to appear in the feed.
+--
+-- - @$url@: URL to the item - this is usually set automatically.
+--
renderRss :: RssConfiguration -- ^ Feed configuration.
-> [Renderable] -- ^ Items to include in the feed.
-> Hakyll ()