summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2010-01-11 08:55:33 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2010-01-11 08:55:33 +0100
commit7c3b55ec27dc76e47eb6175d7e2c32cfadb6dd1b (patch)
tree75700a15cb55bbe2880a02bdf949907f892c3a20 /examples
parent8548888d1c6e937bc7de2b8802ba9b9ee5a432f4 (diff)
downloadhakyll-7c3b55ec27dc76e47eb6175d7e2c32cfadb6dd1b.tar.gz
Ported the tutorials.
Diffstat (limited to 'examples')
-rw-r--r--examples/hakyll/tutorial1.markdown19
-rw-r--r--examples/hakyll/tutorial2.markdown10
-rw-r--r--examples/hakyll/tutorial3.markdown2
-rw-r--r--examples/hakyll/tutorial4.markdown5
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
<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
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}
<li>
- <a href="/$url">$title</a>
+ <a href="$root/$url">$title</a>
- <em>$date</em> - by <em>$author</em>
</li>
~~~~~
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}
<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"
diff --git a/examples/hakyll/tutorial4.markdown b/examples/hakyll/tutorial4.markdown
index e8db0fb..82e246a 100644
--- a/examples/hakyll/tutorial4.markdown
+++ b/examples/hakyll/tutorial4.markdown
@@ -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