4

I would like to filter some posts of my website based on a metadata value. I would like to create a specific metadata called status (like title or date) which could take several values (draft, published, archive) :

---
title: The title
author: Myself
date: 2016-11-29
tags: tag1, tag2
status: draft
---

According to the value of the status metadata, the post should be published or not.

I have a look in the hackage documentation but I'm not sure of the functions to use.

Do you know how to make that with Hakyll ?

Redu
  • 25,060
  • 6
  • 56
  • 76
JeanJouX
  • 2,555
  • 1
  • 25
  • 37

1 Answers1

6

You are probably looking for matchMetadata:

matchMetadata :: Pattern -> (Metadata -> Bool) -> Rules () -> Rules ()

With it, instead of, say...

match "posts/*.md" $ do -- etc.

... you might have:

matchMetadata "posts/*.md" (\m -> lookupString "status" m == Just "published") $ do -- etc.
duplode
  • 33,731
  • 7
  • 79
  • 150