Ported the tutorials.

This commit is contained in:
Jasper Van der Jeugt 2010-01-11 08:55:33 +01:00
parent 8548888d1c
commit 7c3b55ec27
4 changed files with 23 additions and 13 deletions

View file

@ -92,14 +92,14 @@ html files) containing a number of keys. The syntax for these keys is
<head>
<title>MyAweSomeCompany - $title</title>
<link rel="stylesheet" type="text/css"
href="css/default.css" />
href="$$root/css/default.css" />
</head>
<body>
<h1>MyAweSomeCompany - $title</h1>
<div id="navigation">
<a href="index.html">Home</a>
<a href="about.html">About</a>
<a href="products.html">Products</a>
<a href="$$root/index.html">Home</a>
<a href="$$root/about.html">About</a>
<a href="$$root/products.html">Products</a>
</div>
$body
@ -114,6 +114,17 @@ body of any page - that is the convention in Hakyll. Also note that in this
case, `$body` would be replaced by a chunk of html - the result of the
markdown-to-html conversion.
## The $$root key
There is one "special" key in Hakyll: the $$root key. What is so special about
it? Well, internally, it is treated differently - but this should not concern
you. The thing is that it is the only key you can also use in **Pages**.
It will be substituted by a relative url part (like `..` or `../..`) so it
points to the root directory of your site. It is recommended to use this
whenever you need it, it can save you some time from messing with absolute
and relative URL's.
## Putting it all together
Now, we'll render the page using the `renderChain` function. This function

View file

@ -93,7 +93,7 @@ the end just `key: value` mappings. A CustomPage is created using the
~~~~~{.haskell}
createCustomPage :: FilePath
-> [FilePath]
-> [(String, Either String (IO ByteString)]
-> [(String, Either String (IO String)]
~~~~~
The first argument is the `url` of the page to generate. For our index page,
@ -106,16 +106,16 @@ This, once again, is about dependency handling. The idea is that you can choose
which type to use for the value:
- `String`: Simply a `String`.
- `IO ByteString`: Here, you can give an arbitrary `IO` action that will result
in a ByteString. However - this action _will not be executed_ when the file
- `IO String`: Here, you can give an arbitrary `IO` action that will result
in a String. However - this action _will not be executed_ when the file
in `_site` is up-to-date.
First, let us define this `IO ByteString` for our index page. We want to render
First, let us define this `IO String` for our index page. We want to render
every post using a simple template:
~~~~~{.html}
<li>
<a href="/$url">$title</a>
<a href="$root/$url">$title</a>
- <em>$date</em> - by <em>$author</em>
</li>
~~~~~

View file

@ -104,7 +104,7 @@ documents, so we'll do this. In `templates/default.html`:
~~~~~~{.html}
<head>
<title>SimpleBlog - $title</title>
<link rel="stylesheet" type="text/css" href="/css/default.css" />
<link rel="stylesheet" type="text/css" href="$$root/css/default.css" />
<link rel="alternate"
type="application/rss+xml"
title="SimpleBlog"

View file

@ -25,7 +25,7 @@ have a look at it's type.
~~~~~{.haskell}
renderValue :: String -> String
-> (ByteString -> ByteString)
-> (String -> String)
-> ContextManipulation
~~~~~
@ -37,11 +37,10 @@ replaced. The third argument is the function to manipulate the `value` with.
As a simple example, let's write a function that puts the `$title` in uppercase.
~~~~~{.haskell}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Char (toUpper)
titleUpper :: ContextManipulation
titleUpper = renderValue "title" "title" $ B.map toUpper
titleUpper = renderValue "title" "title" $ map toUpper
~~~~~
## Applying Context Manipulations