summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/example/site.hs8
-rw-r--r--src/Hakyll/Core/Configuration.hs8
-rw-r--r--src/Hakyll/Core/Routes.hs4
-rw-r--r--web/tutorials/02-basics.markdown68
4 files changed, 73 insertions, 15 deletions
diff --git a/data/example/site.hs b/data/example/site.hs
index 9c24b34..60369ed 100644
--- a/data/example/site.hs
+++ b/data/example/site.hs
@@ -18,17 +18,9 @@ main = hakyll $ do
match (fromList ["about.rst", "contact.markdown"]) $ do
route $ setExtension "html"
- compile $ do
-
- defaultTpl <- loadBody "templates/default.html"
- pageCompiler
- >>= applyTemplate defaultTpl defaultContext
- >>= relativizeUrls
- {-
compile $ pageCompiler
>>= loadAndApplyTemplate "templates/default.html" defaultContext
>>= relativizeUrls
- -}
match "posts/*" $ do
route $ setExtension "html"
diff --git a/src/Hakyll/Core/Configuration.hs b/src/Hakyll/Core/Configuration.hs
index 4d34114..b5b5f77 100644
--- a/src/Hakyll/Core/Configuration.hs
+++ b/src/Hakyll/Core/Configuration.hs
@@ -28,7 +28,7 @@ data Configuration = Configuration
providerDirectory :: FilePath
, -- | Function to determine ignored files
--
- -- In 'defaultHakyllConfiguration', the following files are ignored:
+ -- In 'defaultConfiguration', the following files are ignored:
--
-- * files starting with a @.@
--
@@ -38,9 +38,9 @@ data Configuration = Configuration
--
-- * files ending with @.swp@
--
- -- Note that the files in @destinationDirectory@ and @storeDirectory@ will
+ -- Note that the files in 'destinationDirectory' and 'storeDirectory' will
-- also be ignored. Note that this is the configuration parameter, if you
- -- want to use the test, you should use @shouldIgnoreFile@.
+ -- want to use the test, you should use 'shouldIgnoreFile'.
--
ignoreFile :: FilePath -> Bool
, -- | Here, you can plug in a system command to upload/deploy your site.
@@ -51,7 +51,7 @@ data Configuration = Configuration
--
-- You can execute this by using
--
- -- > ./hakyll deploy
+ -- > ./site deploy
--
deployCommand :: String
, -- | Use an in-memory cache for items. This is faster but uses more
diff --git a/src/Hakyll/Core/Routes.hs b/src/Hakyll/Core/Routes.hs
index 27e03b1..f653fa5 100644
--- a/src/Hakyll/Core/Routes.hs
+++ b/src/Hakyll/Core/Routes.hs
@@ -138,8 +138,8 @@ gsubRoute pattern replacement = customRoute $
--------------------------------------------------------------------------------
--- | Compose routes so that @f `composeRoutes` g@ is more or less equivalent
--- with @f >>> g@.
+-- | Compose routes so that @f \`composeRoutes\` g@ is more or less equivalent
+-- with @g . f@.
--
-- Example:
--
diff --git a/web/tutorials/02-basics.markdown b/web/tutorials/02-basics.markdown
index f29b549..f4d781b 100644
--- a/web/tutorials/02-basics.markdown
+++ b/web/tutorials/02-basics.markdown
@@ -22,7 +22,73 @@ In general, it's only necessary to use `rebuild` when you made changes to your
Basic rules
-----------
-TODO
+Let's take a look at the `site.hs` file.
+
+```haskell
+main :: IO ()
+main = hakyll $ do
+ ...
+```
+
+Hakyll configurations are in the `Rules` monad. In order to run them, the
+`hakyll` function is used, so your main function usually starts this way.
+`hakyllWith` is also available, this function allows you specify a custom
+[Configuration].
+
+[Configuration]: /reference/Hakyll-Core-Configuration.html
+
+Some actual rules look like this:
+
+```haskell
+match "images/*" $ do
+ route idRoute
+ compile copyFileCompiler
+
+match "css/*" $ do
+ route idRoute
+ compile compressCssCompiler
+
+```
+
+This is a declarative DSL: the order in which you write the rules make little
+difference: Hakyll will use dependency tracking to determine the correct order.
+
+We group the different rules using `match`. The first argument for `match` is a
+[Pattern]. The `OverloadedStrings` extension allows us to just write `String`s
+here, which are interpreted as globs --- all files in the `images/` directory,
+and all files in the `css/` directory.
+
+[Pattern]: /reference/Hakyll-Core-Identifier-Pattern.html
+
+Basic routes
+------------
+
+The `route` function is used for determining the output file. For example, you
+probably want to write the processed contents of `contact.markdown` to
+`_site/contact.html` and not `_site/contact.markdown`.
+
+`idRoute` is a commonly used and just keeps the filename. We use this for e.g.
+the images and CSS files.
+
+`setExtension` is another common route which takes a single argument: the
+extension of the resulting file. In order to route `contact.markdown` to
+`_site/contact.html`, use:
+
+```haskell
+route $ setExtension "html"
+```
+
+`customRoute` is a more advanced higher-order function which allows for even
+more customization. You want to route `contact.markdown` to
+`_site/nwodkram.tcatnoc`? No problem, just use:
+
+```haskell
+customRoute $ reverse . toFilePath
+```
+
+More information can be found in the [Routes] module.
+
+[Routes]: /reference/Hakyll-Core-Routes.html
## Images