match package:hakyll

Add a selection of which source files to process (using the given glob pattern) to the given remaining Rules value. The expanded, relative path of the matched source file on disk (relative to the project directory configured with providerDirectory) becomes the identifier under which the compilation result is saved to the Store (in case you want to load it within another rule). See Identifier for details.

Examples

Select all markdown files within a directory (but without subdirectories)
-- Match all Markdown files in the immediate 'posts' directory
-- e.g. '<project-directory>/posts/hakyll.md'
-- but NOT  '<project-directory>/posts/haskell/monad.md'
match "posts/*.md" $ do
route $ setExtension "html"
compile pandocCompiler
Select all markdown files within a directory (including subdirectories recursively)
-- Match all Markdown files in the 'posts' directory and any subdirectory
-- e.g. '<project-directory>/posts/hakyll.md'
-- and  '<project-directory>/posts/haskell/monad.md'
match "posts/**.md" $ do
route $ setExtension "html"
compile pandocCompiler
See Pattern or search "glob patterns" online for more details. To control where the compilation result will be written out, use routing functions like setExtension.
Check if an identifier matches a pattern
Apply the route if the identifier matches the given pattern, fail otherwise
Add a selection of which source files to process (using the given glob pattern and metadata predicate) to the given remaining Rules values. Same as match but allows to filter files further based on their (metadata) content (a file is added only when the metadata predicate returns True). The expanded, relative path of the matched source file on disk (relative to the project directory configured with providerDirectory) becomes the identifier under which the compilation result is saved to the Store (in case you want to load it within another rule). See Identifier for details.

Examples

Select all markdown files with enabled draft flag within a directory
matchMetadata "posts/*.md" (\meta -> maybe False (=="true") $ lookupString "draft" meta) $ do
route $ setExtension "html"
compile pandocCompiler
For example, the following 'posts/hakyll.md' file with draft: true metadata would match:
---
draft: true
title: Hakyll Post
...
---
In this blog post we learn about Hakyll ...
Note that files that have draft: false or no such draft field at all, would not match. You can use helper functions like lookupString to access a specific metadata field, and maybe to work with Maybe. To control where the compilation result will be written out, use routing functions like setExtension.
Given a list of identifiers, retain only those who match the given pattern