summaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rw-r--r--web/site.hs6
-rw-r--r--web/tutorials/a-guide-to-the-hakyll-module-zoo.markdown (renamed from web/tutorials/guide.markdown)0
-rw-r--r--web/tutorials/using-clay-with-hakyll.markdown38
3 files changed, 43 insertions, 1 deletions
diff --git a/web/site.hs b/web/site.hs
index 2fca8e0..0f99af2 100644
--- a/web/site.hs
+++ b/web/site.hs
@@ -3,6 +3,7 @@
import Control.Applicative ((<$>))
import Control.Arrow (second)
import Control.Monad (forM_)
+import Data.Char (isDigit)
import Data.List (isPrefixOf, partition)
import Data.Monoid (mappend)
import Hakyll
@@ -111,4 +112,7 @@ hackage url
--------------------------------------------------------------------------------
-- | Partition tutorials into tutorial series & other articles
partitionTutorials :: [Item a] -> ([Item a], [Item a])
-partitionTutorials = partition $ matches (fromRegex "\\d*-.*") . itemIdentifier
+partitionTutorials = partition $ \i ->
+ case splitPath (toFilePath $ itemIdentifier i) of
+ [_, (x : _)] -> isDigit x
+ _ -> False
diff --git a/web/tutorials/guide.markdown b/web/tutorials/a-guide-to-the-hakyll-module-zoo.markdown
index 8376952..8376952 100644
--- a/web/tutorials/guide.markdown
+++ b/web/tutorials/a-guide-to-the-hakyll-module-zoo.markdown
diff --git a/web/tutorials/using-clay-with-hakyll.markdown b/web/tutorials/using-clay-with-hakyll.markdown
new file mode 100644
index 0000000..e557c3d
--- /dev/null
+++ b/web/tutorials/using-clay-with-hakyll.markdown
@@ -0,0 +1,38 @@
+---
+title: Using Clay with Hakyll
+author: Jasper Van der Jeugt
+---
+
+[Clay](http://sebastiaanvisser.github.com/clay/) is a nice CSS preprocesser
+written in Haskell. There are multiple options to use this together with Hakyll,
+but in this short tutorial I focus on what I think is the best way.
+
+This method requires every Clay file to have a `main` function which just prints
+the CSS. This would be an example of such a file:
+
+``` haskell
+{-# LANGUAGE OverloadedStrings #-}
+import Clay
+import qualified Data.Text.Lazy.IO as T
+
+test :: Css
+test = ...
+
+main :: IO ()
+main = T.putStr $ render test
+```
+
+Let's assume such a file is called `css/foo.hs`. In our compiled site, we want
+to map this to `css/foo.css`. Hence, the route is a simple `setExtension`. For
+compilation, we simply pass the Clay file through `runghc` with no options.
+
+```haskell
+match "css/*.hs" $ do
+ route $ setExtension "css"
+ compile $ getResourceString >>= withItemBody (unixFilter "runghc" [])
+```
+
+The major advantage of using this method (as opposed to importing the Clay files
+in `site.hs`) is that now Hakyll will only recompile the Clay files when
+necessary, and you don't have to manually recompile your `site.hs` each time you
+want to tweak your CSS a little.