@@ -1,92 +0,0 @@
1−--------------------------------------------------------------------------------
2−-- | A page is a key-value mapping, representing a page on your site
3−--
4−-- A page is an important concept in Hakyll. It is a key-value mapping, and has
5−-- one field with an arbitrary type. A 'Page' thus consists of
6−--
7−-- * metadata (of the type @Map String String@);
8−--
9−-- * the actual value (of the type @a@).
10−--
11−-- Usually, the value will be a 'String' as well, and the value will be the body
12−-- of the page.
13−--
14−-- However, this is certainly no restriction. For example, @Page ByteString@
15−-- could be used to represent a binary item (e.g. an image) and some metadata.
16−--
17−-- Pages can be constructed using Haskell, but they are usually parsed from a
18−-- file. The file format for pages is pretty straightforward.
19−--
20−-- > This is a simple page
21−-- > consisting of two lines.
22−--
23−-- This is a valid page with two lines. If we load this in Hakyll, there would
24−-- be no metadata, and the body would be the given text. Let's look at a page
25−-- with some metadata:
26−--
27−-- > ---
28−-- > title: Alice's Adventures in Wonderland
29−-- > author: Lewis Caroll
30−-- > year: 1865
31−-- > ---
32−-- >
33−-- > Chapter I
34−-- > =========
35−-- >
36−-- > Down the Rabbit-Hole
37−-- > --------------------
38−-- >
39−-- > Alice was beginning to get very tired of sitting by her sister on the bank,
40−-- > and of having nothing to do: once or twice she had peeped into the book her
41−-- > sister was reading, but it had no pictures or conversations in it, "and
42−-- > what is the use of a book," thought Alice "without pictures or
43−-- > conversation?"
44−-- >
45−-- > ...
46−--
47−-- As you can see, we construct a metadata header in Hakyll using @---@. Then,
48−-- we simply list all @key: value@ pairs, and end with @---@ again. This page
49−-- contains three metadata fields and a body. The body is given in markdown
50−-- format, which can be easily rendered to HTML by Hakyll, using pandoc.
51−module Hakyll.Web.Page
52− ( pageCompiler
53− , pageCompilerWith
54− , pageCompilerWithPandoc
55− ) where
56−
57−
58−--------------------------------------------------------------------------------
59−import Control.Applicative ((<$>))
60−import Text.Pandoc (Pandoc, ParserState, WriterOptions)
61−
62−
63−--------------------------------------------------------------------------------
64−import Hakyll.Core.Compiler
65−import Hakyll.Core.Item
66−import Hakyll.Web.Pandoc
67−
68−
69−--------------------------------------------------------------------------------
70−-- | Read a page render using pandoc
71−pageCompiler :: Compiler (Item String)
72−pageCompiler =
73− pageCompilerWith defaultHakyllParserState defaultHakyllWriterOptions
74−
75−
76−--------------------------------------------------------------------------------
77−-- | A version of 'pageCompiler' which allows you to specify your own pandoc
78−-- options
79−pageCompilerWith :: ParserState -> WriterOptions -> Compiler (Item String)
80−pageCompilerWith state options = pageCompilerWithPandoc state options id
81−
82−
83−--------------------------------------------------------------------------------
84−-- | An extension of 'pageCompilerWith' which allows you to specify a custom
85−-- pandoc transformation for the content
86−pageCompilerWithPandoc :: ParserState -> WriterOptions
87− -> (Pandoc -> Pandoc)
88− -> Compiler (Item String)
89−pageCompilerWithPandoc state options f = cached cacheName $
90− writePandocWith options . fmap f . readPandocWith state <$> getResourceBody
91− where
92− cacheName = "Hakyll.Web.Page.pageCompilerWithPandoc"