summaryrefslogtreecommitdiff
path: root/README.markdown
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2009-12-03 19:42:23 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2009-12-03 19:42:23 +0100
commit0a75e1e2b92a73aeff46d7f6631c733186214fa0 (patch)
treed3d447a9b54f297b448a469d61908dba1a1910e3 /README.markdown
parentc8e2dfbf995c5c0662610b688a5fd763f5042f22 (diff)
downloadhakyll-0a75e1e2b92a73aeff46d7f6631c733186214fa0.tar.gz
Wrote on README.
Diffstat (limited to 'README.markdown')
-rw-r--r--README.markdown68
1 files changed, 67 insertions, 1 deletions
diff --git a/README.markdown b/README.markdown
index a4bed8c..aed627b 100644
--- a/README.markdown
+++ b/README.markdown
@@ -10,6 +10,18 @@ Inspired by [xmonad](http://xmonad.org), a small Haskell program is used as
configuration file. In this file, you give instructions on how the site should
be generated. In the rest of this document, we will examine a small example.
+This is our directory layout:
+
+ |-- _site
+ |-- favicon.ico
+ |-- hakyll.hs
+ |-- images
+ | `-- foo.png
+ |-- templates
+ | |-- default.html
+ | `-- sample.html
+ `-- text.markdown
+
## Static files
Static files can be rendered using the `static` command. This command ensures
@@ -110,4 +122,58 @@ function uses to determine the file destination.
Sometimes, you want to create a `Page` from scratch, without reading from a
file. There are functions to do that for you, and I suggest you read the
-documentation of `Text.Hakyll.Page`.
+documentation of `Text.Hakyll.Page`. As a more advanced example, I will
+explain the RSS system I wrote for my website.
+
+ |-- generate.hs
+ |-- posts
+ | `-- 2009-12-02-a-first-post.markdown
+ `-- templates
+ |-- rss.xml
+ `-- rssitem.xml
+
+Our post contains some metadata:
+
+ ---
+ title: A first post
+ date: December 2, 2009
+ ---
+
+ # A first post
+
+ A first post describing the technical setup of this blog, for that is
+
+The `templates/rssitem.xml` file is a template for rendering one post to an
+rss item:
+
+ <item>
+ <title>$title</title>
+ <link>http://jaspervdj.be/$url</link>
+ <description>New blogpost: $title</description>
+ </item>
+
+Now a template for rendering the whole rss feed, `templates/rss.xml`:
+
+ <?xml version="1.0" ?>
+ <rss version="2.0">
+ <channel>
+ <title>jaspervdj - a personal blog</title>
+ <link>http://jaspervdj.be/</link>
+ <description>Personal blog of jaspervdj</description>
+ $items
+ </channel>
+ </rss>
+
+Alright, let's get coding.
+
+ -- Find all posts paths.
+ postPaths <- liftM (L.reverse . L.sort) $ getRecursiveContents "posts"
+ -- Read and render all posts with the rssitem.xml template
+ -- Also, only render 5 posts.
+ pages <- mapM readPage (take 5 postPaths)
+ items <- mapM (renderPage "templates/rssitem.xml") pages
+ -- Render the result
+ renderAndWrite "templates/rss.xml" $ pageFromList [ ("items", concatPages items),
+ ("url", "rss.xml") ]
+
+That's that. Now we have a nice rss feed.