From 7c3b55ec27dc76e47eb6175d7e2c32cfadb6dd1b Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Mon, 11 Jan 2010 08:55:33 +0100 Subject: [PATCH] Ported the tutorials. --- examples/hakyll/tutorial1.markdown | 19 +++++++++++++++---- examples/hakyll/tutorial2.markdown | 10 +++++----- examples/hakyll/tutorial3.markdown | 2 +- examples/hakyll/tutorial4.markdown | 5 ++--- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/examples/hakyll/tutorial1.markdown b/examples/hakyll/tutorial1.markdown index 56fb9e4..5ba57e6 100644 --- a/examples/hakyll/tutorial1.markdown +++ b/examples/hakyll/tutorial1.markdown @@ -92,14 +92,14 @@ html files) containing a number of keys. The syntax for these keys is MyAweSomeCompany - $title + href="$$root/css/default.css" />

MyAweSomeCompany - $title

$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 diff --git a/examples/hakyll/tutorial2.markdown b/examples/hakyll/tutorial2.markdown index 16521ac..0a1e194 100644 --- a/examples/hakyll/tutorial2.markdown +++ b/examples/hakyll/tutorial2.markdown @@ -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}
  • - $title + $title - $date - by $author
  • ~~~~~ diff --git a/examples/hakyll/tutorial3.markdown b/examples/hakyll/tutorial3.markdown index 2c3acf9..e241d63 100644 --- a/examples/hakyll/tutorial3.markdown +++ b/examples/hakyll/tutorial3.markdown @@ -104,7 +104,7 @@ documents, so we'll do this. In `templates/default.html`: ~~~~~~{.html} SimpleBlog - $title - + 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