on master help sign in
Write a little bit
9b081b6Jasper Van der Jeugt
web/tutorials/02-basics.markdown+2
@@ -99,6 +99,8 @@ some common examples:
99
99
100- `copyFileCompiler` is self-explanatory, the output is exactly the same as the
100- `copyFileCompiler` is self-explanatory, the output is exactly the same as the
101 input;
101 input;
102+- `getResourceBody` just gets you the content as a `String`, so you can perform
103+ other manipulations afterwards;
102- `compressCssCompiler` performs some simple build-in compression
104- `compressCssCompiler` performs some simple build-in compression
103 transformations for CSS;
105 transformations for CSS;
104- `pandocCompiler` reads markdown, reStructuredText, or another input format and
106- `pandocCompiler` reads markdown, reStructuredText, or another input format and
web/tutorials/03-compilers.markdown+27−6
@@ -1,12 +1,33 @@
1---
1---
2−title: Using and writing Compilers
2+title: More on compilers: load, and templates
3author: Jasper Van der Jeugt
3author: Jasper Van der Jeugt
4---
4---
5
5
6−Identifier, Item, Compiler
6+Loading items
7−--------------------------
7+-------------
8
8
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.
10
11
11−- `Identifier` is a string-like value which uniquely identifies a single item
12+Suppose that you're generating `index.html` which shows your latest brilliant
12− for your webpage
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+```