Update hakyll site to hakyll3

This commit is contained in:
Jasper Van der Jeugt 2011-02-12 15:16:42 +01:00
parent 6e2cc76928
commit 645ac84b63
5 changed files with 64 additions and 49 deletions

View file

@ -75,6 +75,10 @@ h3 {
text-transform: uppercase;
}
h1 a, h2 a, h3 a {
text-decoration: none;
}
div.column {
width: 50%;
float: left;

View file

@ -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 = "<h2>Table of contents</h2>\n$toc$\n$body$"
, writerStandalone = True
}
pages = [ "about.markdown"
, "changelog.markdown"
, "index.markdown"
, "philosophy.markdown"
, "reference.markdown"
]

View file

@ -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)

View file

@ -4,11 +4,11 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Hakyll - $title</title>
<title>Hakyll - $title$</title>
<!-- Stylesheets. -->
<link rel="stylesheet" type="text/css" href="$root/css/default.css" />
<link rel="stylesheet" type="text/css" href="$root/css/syntax.css" />
<link rel="stylesheet" type="text/css" href="/css/default.css" />
<link rel="stylesheet" type="text/css" href="/css/syntax.css" />
<!-- Metadata. -->
<meta name="keywords" content="hakyll,static site generator,static,site,generator,haskell,blog"/>
@ -17,16 +17,16 @@
<body>
<div id="main">
<div id="header">
<img src="$root/images/lambda.png" alt="lambda" />
<h1>Hakyll - $title</h1>
<img src="/images/lambda.png" alt="lambda" />
<h1>Hakyll - $title$</h1>
</div>
<!-- Sidebar. -->
<div id="sidebar">
$sidebar
$sidebar$
</div>
<div id="content">
$body
$body$
</div>
<div id="footer">

View file

@ -1,5 +1,6 @@
The Hakyll Tutorial
===================
---
title: Tutorial
---
Why static websites?
--------------------