on master help sign in
Write a little bit
commit9b081b60a26a58aad890252cd561ddc1a5a34385 authorJasper Van der Jeugt <m@jaspervdj.be> dateSat 15 Dec 2012, 20:01 (14 years ago) parentcb79c45
2 files changed+29−6
web/tutorials/02-basics.markdown+2 web/tutorials/03-compilers.markdown+27−6
web/tutorials/02-basics.markdown+2
@@ -99,6 +99,8 @@ some common examples:
9999
100100- `copyFileCompiler` is self-explanatory, the output is exactly the same as the
101101 input;
102+- `getResourceBody` just gets you the content as a `String`, so you can perform
103+ other manipulations afterwards;
102104- `compressCssCompiler` performs some simple build-in compression
103105 transformations for CSS;
104106- `pandocCompiler` reads markdown, reStructuredText, or another input format and
web/tutorials/03-compilers.markdown+27−6
@@ -1,12 +1,33 @@
11---
2−title: Using and writing Compilers
2+title: More on compilers: load, and templates
33author: Jasper Van der Jeugt
44---
55
6−Identifier, Item, Compiler
7−--------------------------
6+Loading items
7+-------------
88
9−Three important, related types are `Identifier`, `Item` and `Compiler`.
9+The compiler Monad is a complex beast, but this is nicely hidden for the user of
10+the Hakyll library.
1011
11−- `Identifier` is a string-like value which uniquely identifies a single item
12− for your webpage
12+Suppose that you're generating `index.html` which shows your latest brilliant
13+blogpost. This requires `posts/foo.markdown` to be generated *before*
14+`index.html` (so we don't have to generate it twice). But you don't have to care
15+about all of that: Hakyll will sort this out this out for you automatically!
16+
17+Let's see some quick examples. We can load a specific item:
18+
19+```haskell
20+load "posts/foo.markdown" :: Compiler (Item String)
21+```
22+
23+Or a whole bunch of them:
24+
25+```haskell
26+loadAll "posts/*" :: Compiler [Item String]
27+```
28+
29+Sometimes you just want the *contents* and not the `Item`:
30+
31+```haskell
32+loadBody "posts/foo.markdown" :: Compiler String
33+```