From 645ac84b636f1a7725f032c2eeff68214aacda64 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Sat, 12 Feb 2011 15:16:42 +0100 Subject: Update hakyll site to hakyll3 --- examples/hakyll/css/default.css | 4 ++ examples/hakyll/hakyll.hs | 77 +++++++++++++++++++--------------- examples/hakyll/sidebar.markdown | 13 +++--- examples/hakyll/templates/default.html | 14 +++---- examples/hakyll/tutorial.markdown | 5 ++- 5 files changed, 64 insertions(+), 49 deletions(-) diff --git a/examples/hakyll/css/default.css b/examples/hakyll/css/default.css index 0e9462c..f895f48 100644 --- a/examples/hakyll/css/default.css +++ b/examples/hakyll/css/default.css @@ -75,6 +75,10 @@ h3 { text-transform: uppercase; } +h1 a, h2 a, h3 a { + text-decoration: none; +} + div.column { width: 50%; float: left; diff --git a/examples/hakyll/hakyll.hs b/examples/hakyll/hakyll.hs index ca4cd6e..92f24c7 100644 --- a/examples/hakyll/hakyll.hs +++ b/examples/hakyll/hakyll.hs @@ -1,39 +1,50 @@ -import Text.Hakyll -import Text.Hakyll.Render -import Text.Hakyll.File -import Text.Hakyll.CreateContext -import Control.Monad.Reader (liftIO) -import System.Directory -import Control.Monad (mapM_, forM_, liftM) -import Data.List (sort) +{-# LANGUAGE OverloadedStrings #-} +import Hakyll +import Control.Monad (forM_) +import Control.Arrow ((>>>), arr) +import Text.Pandoc (writerTableOfContents, writerTemplate, writerStandalone) -main = hakyll "http://jaspervdj.be/hakyll" $ do - directory css "css" - directory static "images" - directory static "examples" - directory static "reference" +main :: IO () +main = hakyll $ do + route "css/*" idRoute + compile "css/*" defaultCompressCss - tutorials <- liftM sort $ getRecursiveContents "tutorials" - let tutorialPage = createListing "tutorials.html" - ["templates/tutorialitem.html"] - (map createPage tutorials) - [("title", Left "Tutorials")] - renderChain ["templates/tutorials.html", "templates/default.html"] - (withSidebar tutorialPage) + -- Static directories + forM_ ["images/*", "examples/*", "reference/*"] $ \f -> do + route f idRoute + compile f defaultCopyFile - mapM_ (render' ["templates/default.html"]) $ - [ "about.markdown" - , "index.markdown" - , "philosophy.markdown" - , "reference.markdown" - , "changelog.markdown" - ] + -- Pages + forM_ pages $ \p -> do + route p $ setExtension "html" + compile p $ defaultPageRead + >>> requireA "sidebar.markdown" (setFieldA "sidebar" $ arr pageBody) + >>> defaultApplyTemplate "templates/default.html" + >>> defaultRelativizeUrls - forM_ tutorials $ render' [ "templates/tutorial.html" - , "templates/default.html" - ] + -- Tutorial + route "tutorial.markdown" $ setExtension "html" + compile "tutorial.markdown" $ pageRead + >>> pageRenderPandocWith defaultParserState withToc + >>> requireA "sidebar.markdown" (setFieldA "sidebar" $ arr pageBody) + >>> defaultApplyTemplate "templates/default.html" + >>> defaultRelativizeUrls + -- Sidebar + compile "sidebar.markdown" defaultPageRead + + -- Templates + compile "templates/*" defaultTemplateRead where - render' templates = renderChain templates . withSidebar . createPage - withSidebar a = a `combine` createPage "sidebar.markdown" - + withToc = defaultWriterOptions + { writerTableOfContents = True + , writerTemplate = "

Table of contents

\n$toc$\n$body$" + , writerStandalone = True + } + + pages = [ "about.markdown" + , "changelog.markdown" + , "index.markdown" + , "philosophy.markdown" + , "reference.markdown" + ] diff --git a/examples/hakyll/sidebar.markdown b/examples/hakyll/sidebar.markdown index 9444c58..fb40b5d 100644 --- a/examples/hakyll/sidebar.markdown +++ b/examples/hakyll/sidebar.markdown @@ -1,9 +1,8 @@ ---- sidebar ## Navigation -[home]($root/index.html) -[philosophy]($root/philosophy.html) -[about]($root/about.html) -[tutorials]($root/tutorials.html) -[reference]($root/reference.html) -[changelog]($root/changelog.html) +[home](/index.html) +[philosophy](/philosophy.html) +[about](/about.html) +[tutorial](/tutorial.html) +[reference](/reference.html) +[changelog](/changelog.html) diff --git a/examples/hakyll/templates/default.html b/examples/hakyll/templates/default.html index 2e94f72..139564b 100644 --- a/examples/hakyll/templates/default.html +++ b/examples/hakyll/templates/default.html @@ -4,11 +4,11 @@ - Hakyll - $title + Hakyll - $title$ - - + + @@ -17,16 +17,16 @@
- $body + $body$