Add Hakyll.Web module
This commit is contained in:
parent
e54834f444
commit
e1aa960099
2 changed files with 22 additions and 1 deletions
21
src/Hakyll/Web.hs
Normal file
21
src/Hakyll/Web.hs
Normal file
|
@ -0,0 +1,21 @@
|
|||
-- | Module exporting commonly used web-related functions
|
||||
--
|
||||
module Hakyll.Web
|
||||
( defaultPageRead
|
||||
, defaultTemplateRead
|
||||
) where
|
||||
|
||||
import Control.Arrow (arr, (>>>), (>>^))
|
||||
|
||||
import Hakyll.Core.Compiler
|
||||
import Hakyll.Web.Page
|
||||
import Hakyll.Web.Pandoc
|
||||
import Hakyll.Web.Template
|
||||
|
||||
defaultPageRead :: Compiler () (Page String)
|
||||
defaultPageRead = cached "Hakyll.Web.defaultPageRead" $
|
||||
pageRead >>> addDefaultFields >>> arr applySelf >>> pageRenderPandoc
|
||||
|
||||
defaultTemplateRead :: Compiler () Template
|
||||
defaultTemplateRead = cached "Hakyll.Web.defaultTemplateRead" $
|
||||
getResourceString >>^ readTemplate
|
|
@ -61,6 +61,6 @@ addDefaultFields = (getRoute &&& id >>^ uncurry addRoute)
|
|||
|
||||
-- Add title and category, based on identifier
|
||||
addIdentifier i = addField "title" (takeBaseName p)
|
||||
. addField "category" (takeBaseName $ takeDirectory p)
|
||||
. addField "category" (takeBaseName $ takeDirectory p)
|
||||
where
|
||||
p = toFilePath i
|
||||
|
|
Loading…
Reference in a new issue