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.