diff options
-rw-r--r-- | examples/brochure/hakyll.hs | 18 | ||||
-rw-r--r-- | examples/feedblog/hakyll.hs | 48 | ||||
-rw-r--r-- | examples/hakyll/hakyll.hs | 34 | ||||
-rw-r--r-- | examples/morepages/hakyll.hs | 23 | ||||
-rw-r--r-- | examples/simpleblog/hakyll.hs | 46 | ||||
-rw-r--r-- | examples/tagblog/hakyll.hs | 52 |
6 files changed, 107 insertions, 114 deletions
diff --git a/examples/brochure/hakyll.hs b/examples/brochure/hakyll.hs index 819924f..1bc5919 100644 --- a/examples/brochure/hakyll.hs +++ b/examples/brochure/hakyll.hs @@ -6,13 +6,15 @@ import Hakyll main :: IO () main = hakyll $ do - route "css/*" idRoute - compile "css/*" compressCssCompiler + match "css/*" $ do + route idRoute + compile compressCssCompiler - compile "templates/*" templateCompiler + match "templates/*" $ compile templateCompiler - forM_ ["about.rst", "index.markdown", "code.lhs"] $ \page -> do - route page $ setExtension "html" - compile page $ pageCompiler - >>> applyTemplateCompiler "templates/default.html" - >>> relativizeUrlsCompiler + forM_ ["about.rst", "index.markdown", "code.lhs"] $ \page -> + match page $ do + route $ setExtension "html" + compile $ pageCompiler + >>> applyTemplateCompiler "templates/default.html" + >>> relativizeUrlsCompiler diff --git a/examples/feedblog/hakyll.hs b/examples/feedblog/hakyll.hs index e10af10..4aa8ed9 100644 --- a/examples/feedblog/hakyll.hs +++ b/examples/feedblog/hakyll.hs @@ -11,47 +11,43 @@ import Hakyll main :: IO () main = hakyll $ do -- Compress CSS - route "css/*" idRoute - compile "css/*" compressCssCompiler + match "css/*" $ do + route idRoute + compile compressCssCompiler -- Render posts - route "posts/*" $ setExtension ".html" - compile "posts/*" $ - pageCompiler + match "posts/*" $ do + route $ setExtension ".html" + compile $ pageCompiler >>> applyTemplateCompiler "templates/post.html" >>> applyTemplateCompiler "templates/default.html" >>> relativizeUrlsCompiler -- Render posts list - route "posts.html" $ idRoute - create "posts.html" $ - constA mempty - >>> arr (setField "title" "All posts") - >>> requireAllA "posts/*" addPostList - >>> applyTemplateCompiler "templates/posts.html" - >>> applyTemplateCompiler "templates/default.html" - >>> relativizeUrlsCompiler + match "posts.html" $ route idRoute + create "posts.html" $ constA mempty + >>> arr (setField "title" "All posts") + >>> requireAllA "posts/*" addPostList + >>> applyTemplateCompiler "templates/posts.html" + >>> applyTemplateCompiler "templates/default.html" + >>> relativizeUrlsCompiler -- Index - route "index.html" $ idRoute - create "index.html" $ - constA mempty - >>> arr (setField "title" "Home") - >>> requireAllA "posts/*" (id *** arr (take 3 . reverse . sortByBaseName) >>> addPostList) - >>> applyTemplateCompiler "templates/index.html" - >>> applyTemplateCompiler "templates/default.html" - >>> relativizeUrlsCompiler + match "index.html" $ route idRoute + create "index.html" $ constA mempty + >>> arr (setField "title" "Home") + >>> requireAllA "posts/*" (id *** arr (take 3 . reverse . sortByBaseName) >>> addPostList) + >>> applyTemplateCompiler "templates/index.html" + >>> applyTemplateCompiler "templates/default.html" + >>> relativizeUrlsCompiler -- Render RSS feed - route "rss.xml" $ idRoute + match "rss.xml" $ route idRoute create "rss.xml" $ requireAll_ "posts/*" >>> renderRss feedConfiguration -- Read templates - compile "templates/*" templateCompiler - - -- End - return () + match "templates/*" $ compile templateCompiler -- | Auxiliary compiler: generate a post list from a list of given posts, and -- add it to the current page under @$posts@ diff --git a/examples/hakyll/hakyll.hs b/examples/hakyll/hakyll.hs index c4f339c..60ddc33 100644 --- a/examples/hakyll/hakyll.hs +++ b/examples/hakyll/hakyll.hs @@ -6,35 +6,37 @@ import Text.Pandoc main :: IO () main = hakyll $ do - route "css/*" idRoute - compile "css/*" compressCssCompiler + match "css/*" $ do + route idRoute + compile compressCssCompiler -- Static directories - forM_ ["images/*", "examples/*", "reference/*"] $ \f -> do - route f idRoute - compile f copyFileCompiler + forM_ ["images/*", "examples/*", "reference/*"] $ \f -> match f $ do + route idRoute + compile copyFileCompiler -- Pages - forM_ pages $ \p -> do - route p $ setExtension "html" - compile p $ pageCompiler + forM_ pages $ \p -> match p $ do + route $ setExtension "html" + compile $ pageCompiler >>> requireA "sidebar.markdown" (setFieldA "sidebar" $ arr pageBody) >>> applyTemplateCompiler "templates/default.html" >>> relativizeUrlsCompiler -- Tutorial - route "tutorial.markdown" $ setExtension "html" - compile "tutorial.markdown" $ readPageCompiler - >>> pageRenderPandocWith defaultHakyllParserState withToc - >>> requireA "sidebar.markdown" (setFieldA "sidebar" $ arr pageBody) - >>> applyTemplateCompiler "templates/default.html" - >>> relativizeUrlsCompiler + match "tutorial.markdown" $ do + route $ setExtension "html" + compile $ readPageCompiler + >>> pageRenderPandocWith defaultHakyllParserState withToc + >>> requireA "sidebar.markdown" (setFieldA "sidebar" $ arr pageBody) + >>> applyTemplateCompiler "templates/default.html" + >>> relativizeUrlsCompiler -- Sidebar - compile "sidebar.markdown" pageCompiler + match "sidebar.markdown" $ compile pageCompiler -- Templates - compile "templates/*" templateCompiler + match "templates/*" $ compile templateCompiler where withToc = defaultHakyllWriterOptions { writerTableOfContents = True diff --git a/examples/morepages/hakyll.hs b/examples/morepages/hakyll.hs index d62f8a8..c1b96e6 100644 --- a/examples/morepages/hakyll.hs +++ b/examples/morepages/hakyll.hs @@ -9,20 +9,21 @@ import Hakyll main :: IO () main = hakyll $ do -- Compress CSS - route "css/*" idRoute - compile "css/*" compressCssCompiler + match "css/*" $ do + route idRoute + compile compressCssCompiler -- Render static pages - forM_ ["about.markdown", "index.markdown", "products.markdown"] $ \p -> do - route p $ setExtension ".html" - compile p $ - pageCompiler - >>> requireA "footer.markdown" (setFieldA "footer" $ arr pageBody) - >>> applyTemplateCompiler "templates/default.html" - >>> relativizeUrlsCompiler + forM_ ["about.markdown", "index.markdown", "products.markdown"] $ \p -> + match p $ do + route $ setExtension ".html" + compile $ pageCompiler + >>> requireA "footer.markdown" (setFieldA "footer" $ arr pageBody) + >>> applyTemplateCompiler "templates/default.html" + >>> relativizeUrlsCompiler -- Compile footer - compile "footer.markdown" pageCompiler + match "footer.markdown" $ compile pageCompiler -- Read templates - compile "templates/*" templateCompiler + match "templates/*" $ compile templateCompiler diff --git a/examples/simpleblog/hakyll.hs b/examples/simpleblog/hakyll.hs index db4230f..270c3e3 100644 --- a/examples/simpleblog/hakyll.hs +++ b/examples/simpleblog/hakyll.hs @@ -11,42 +11,38 @@ import Hakyll main :: IO () main = hakyll $ do -- Compress CSS - route "css/*" idRoute - compile "css/*" compressCssCompiler + match "css/*" $ do + route idRoute + compile compressCssCompiler -- Render posts - route "posts/*" $ setExtension ".html" - compile "posts/*" $ - pageCompiler + match "posts/*" $ do + route $ setExtension ".html" + compile $ pageCompiler >>> applyTemplateCompiler "templates/post.html" >>> applyTemplateCompiler "templates/default.html" >>> relativizeUrlsCompiler -- Render posts list - route "posts.html" $ idRoute - create "posts.html" $ - constA mempty - >>> arr (setField "title" "All posts") - >>> requireAllA "posts/*" addPostList - >>> applyTemplateCompiler "templates/posts.html" - >>> applyTemplateCompiler "templates/default.html" - >>> relativizeUrlsCompiler + match "posts.html" $ route idRoute + create "posts.html" $ constA mempty + >>> arr (setField "title" "All posts") + >>> requireAllA "posts/*" addPostList + >>> applyTemplateCompiler "templates/posts.html" + >>> applyTemplateCompiler "templates/default.html" + >>> relativizeUrlsCompiler -- Index - route "index.html" idRoute - create "index.html" $ - constA mempty - >>> arr (setField "title" "Home") - >>> requireAllA "posts/*" (id *** arr (take 3 . reverse . sortByBaseName) >>> addPostList) - >>> applyTemplateCompiler "templates/index.html" - >>> applyTemplateCompiler "templates/default.html" - >>> relativizeUrlsCompiler + match "index.html" $ route idRoute + create "index.html" $ constA mempty + >>> arr (setField "title" "Home") + >>> requireAllA "posts/*" (id *** arr (take 3 . reverse . sortByBaseName) >>> addPostList) + >>> applyTemplateCompiler "templates/index.html" + >>> applyTemplateCompiler "templates/default.html" + >>> relativizeUrlsCompiler -- Read templates - compile "templates/*" templateCompiler - - -- End - return () + match "templates/*" $ compile templateCompiler -- | Auxiliary compiler: generate a post list from a list of given posts, and -- add it to the current page under @$posts@ diff --git a/examples/tagblog/hakyll.hs b/examples/tagblog/hakyll.hs index 976a017..53e635f 100644 --- a/examples/tagblog/hakyll.hs +++ b/examples/tagblog/hakyll.hs @@ -12,13 +12,14 @@ import Hakyll main :: IO () main = hakyll $ do -- Compress CSS - route "css/*" idRoute - compile "css/*" compressCssCompiler + match "css/*" $ do + route idRoute + compile compressCssCompiler -- Render posts - route "posts/*" $ setExtension ".html" - compile "posts/*" $ - pageCompiler + match "posts/*" $ do + route $ setExtension ".html" + compile $ pageCompiler >>> arr (renderDateField "date" "%B %e, %Y" "Date unknown") >>> renderTagsField "prettytags" (fromCaptureString "tags/*") >>> applyTemplateCompiler "templates/post.html" @@ -26,48 +27,43 @@ main = hakyll $ do >>> relativizeUrlsCompiler -- Render posts list - route "posts.html" $ idRoute - create "posts.html" $ - constA mempty - >>> arr (setField "title" "All posts") - >>> requireAllA "posts/*" addPostList - >>> applyTemplateCompiler "templates/posts.html" - >>> applyTemplateCompiler "templates/default.html" - >>> relativizeUrlsCompiler + match "posts.html" $ route idRoute + create "posts.html" $ constA mempty + >>> arr (setField "title" "All posts") + >>> requireAllA "posts/*" addPostList + >>> applyTemplateCompiler "templates/posts.html" + >>> applyTemplateCompiler "templates/default.html" + >>> relativizeUrlsCompiler -- Index - route "index.html" $ idRoute - create "index.html" $ - constA mempty - >>> arr (setField "title" "Home") - >>> requireA "tags" (setFieldA "tagcloud" (renderTagCloud')) - >>> requireAllA "posts/*" (id *** arr (take 3 . reverse . sortByBaseName) >>> addPostList) - >>> applyTemplateCompiler "templates/index.html" - >>> applyTemplateCompiler "templates/default.html" - >>> relativizeUrlsCompiler + match "index.html" $ route idRoute + create "index.html" $ constA mempty + >>> arr (setField "title" "Home") + >>> requireA "tags" (setFieldA "tagcloud" (renderTagCloud')) + >>> requireAllA "posts/*" (id *** arr (take 3 . reverse . sortByBaseName) >>> addPostList) + >>> applyTemplateCompiler "templates/index.html" + >>> applyTemplateCompiler "templates/default.html" + >>> relativizeUrlsCompiler -- Tags create "tags" $ requireAll "posts/*" (\_ ps -> readTags ps :: Tags String) -- Add a tag list compiler for every tag - route "tags/*" $ setExtension ".html" + match "tags/*" $ route $ setExtension ".html" metaCompile $ require_ "tags" >>> arr (M.toList . tagsMap) >>> arr (map (\(t, p) -> (tagIdentifier t, makeTagList t p))) -- Render RSS feed - route "rss.xml" $ idRoute + match "rss.xml" $ route idRoute create "rss.xml" $ requireAll_ "posts/*" >>> mapCompiler (arr $ copyBodyToField "description") >>> renderRss feedConfiguration -- Read templates - compile "templates/*" templateCompiler - - -- End - return () + match "templates/*" $ compile templateCompiler where renderTagCloud' :: Compiler (Tags String) String renderTagCloud' = renderTagCloud tagIdentifier 100 120 |