Discussion:
[hakyll] ANN: Hakyll 4.8
Jasper Van der Jeugt
2016-04-19 17:47:26 UTC
Permalink
Hi all,

I've just released Hakyll-4.8. The main change is that we now use the
yaml package to parse page metadata. This was a frequently requested
feature and it will allow for having more structure in your metadata.

The metadata type changed from:

type Metadata = Map String String

To:

type Metadata = Aeson.Object

Most configurations do not rely on the internals of this object, so
this should not pose a big problem.

What can happen is that your metadata contains invalid YAML, e.g.:

---
title: My first blogpost: Hello world
---

The ':' character is invalid, and you would have to change this to:

---
title: 'My first blogpost: Hello world'
---

Hakyll will generate a nice error message if you have this problem
anywhere in your posts, so this should be easy to fix.

Let me know if you run into any trouble.

Peace,
Jasper
--
You received this message because you are subscribed to the Google Groups "hakyll" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hakyll+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Sergey Bushnyak
2016-05-25 18:39:45 UTC
Permalink
Just switch to new 4.8 and I'm using Metadata heavily to manipulate
different parts based on meta, because some parts of meta considered
optional.
For those who will make changes, here is example code.

```
titleCtx :: Context a
titleCtx =
field "ptitle" $ \item ->
do
metadata <- getMetadata $ itemIdentifier item
let title =
case Map.lookup "title" metadata of
Just value -> "Sigrlami - " ++ value
Nothing -> "Sigrlami"
return title
```
will change to

```
import Data.Aeson.Types
import qualified Data.HashMap.Strict as HM

titleCtx :: Context a
titleCtx =
field "ptitle" $ \item ->
do
metadata <- getMetadata $ itemIdentifier item
let title =
case HM.lookup "title" metadata of
Nothing -> []
Just value -> -- this is not actual value, case it again
case value of
String x -> "Sigrlami - " ++ T.unpack x
_ -> "Sigrlami"
return title
```
and you'll need to add `aeson` and `unordered-containers` to your cabal
dependencies.

Hope this will help someone.
Post by Jasper Van der Jeugt
Hi all,
I've just released Hakyll-4.8. The main change is that we now use the
yaml package to parse page metadata. This was a frequently requested
feature and it will allow for having more structure in your metadata.
type Metadata = Map String String
type Metadata = Aeson.Object
Most configurations do not rely on the internals of this object, so
this should not pose a big problem.
---
title: My first blogpost: Hello world
---
---
title: 'My first blogpost: Hello world'
---
Hakyll will generate a nice error message if you have this problem
anywhere in your posts, so this should be easy to fix.
Let me know if you run into any trouble.
Peace,
Jasper
--
You received this message because you are subscribed to the Google Groups "hakyll" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hakyll+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Sergey Bushnyak
2016-05-25 18:59:13 UTC
Permalink
Just switched to the 4.8 and needed to apply changes. I'm using Metadata
heavily to manipulate different parts based of page based on meta, some
parts of it considered optional.
For those who will also need changes, here is an example code.

```
titleCtx :: Context a
titleCtx =
field "ptitle" $ \item ->
do
metadata <- getMetadata $ itemIdentifier item
let title =
case Map.lookup "title" metadata of
Just value -> "Sigrlami - " ++ value
Nothing -> "Sigrlami"
return title
```
will change to

```
import Data.Aeson.Types
import qualified Data.HashMap.Strict as HM

titleCtx :: Context a
titleCtx =
field "ptitle" $ \item ->
do
metadata <- getMetadata $ itemIdentifier item
let title =
case HM.lookup "title" metadata of
Nothing -> ""
Just value -> -- this is not actual value, case it again
case value of
String x -> "Sigrlami - " ++ T.unpack x
_ -> "Sigrlami"
return title
```
and you'll need to add `aeson` and `unordered-containers` to your cabal
dependencies.

Hope this will help someone.
Post by Jasper Van der Jeugt
Hi all,
I've just released Hakyll-4.8. The main change is that we now use the
yaml package to parse page metadata. This was a frequently requested
feature and it will allow for having more structure in your metadata.
type Metadata = Map String String
type Metadata = Aeson.Object
Most configurations do not rely on the internals of this object, so
this should not pose a big problem.
---
title: My first blogpost: Hello world
---
---
title: 'My first blogpost: Hello world'
---
Hakyll will generate a nice error message if you have this problem
anywhere in your posts, so this should be easy to fix.
Let me know if you run into any trouble.
Peace,
Jasper
--
You received this message because you are subscribed to the Google Groups "hakyll" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hakyll+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
k***@eunchan.net
2016-09-21 02:25:52 UTC
Permalink
Hi,

What I did was to use 'lookupString' function inside Hakyll.Core.Metadata

Here's excerpt from the code:

-- | Filter Public for match funciton
-- Usage : matchMetadata "pattern/**" postIsPublic
metadataFieldIs :: String -> String -> Metadata -> Bool
metadataFieldIs key value metadata =
case lookupString key metadata of
Just v -> value == v
Nothing -> False


Regards,
Eunchan
Post by Sergey Bushnyak
Just switched to the 4.8 and needed to apply changes. I'm using Metadata
heavily to manipulate different parts based of page based on meta, some
parts of it considered optional.
For those who will also need changes, here is an example code.
```
titleCtx :: Context a
titleCtx =
field "ptitle" $ \item ->
do
metadata <- getMetadata $ itemIdentifier item
let title =
case Map.lookup "title" metadata of
Just value -> "Sigrlami - " ++ value
Nothing -> "Sigrlami"
return title
```
will change to
```
import Data.Aeson.Types
import qualified Data.HashMap.Strict as HM
titleCtx :: Context a
titleCtx =
field "ptitle" $ \item ->
do
metadata <- getMetadata $ itemIdentifier item
let title =
case HM.lookup "title" metadata of
Nothing -> ""
Just value -> -- this is not actual value, case it again
case value of
String x -> "Sigrlami - " ++ T.unpack x
_ -> "Sigrlami"
return title
```
and you'll need to add `aeson` and `unordered-containers` to your cabal
dependencies.
Hope this will help someone.
Post by Jasper Van der Jeugt
Hi all,
I've just released Hakyll-4.8. The main change is that we now use the
yaml package to parse page metadata. This was a frequently requested
feature and it will allow for having more structure in your metadata.
type Metadata = Map String String
type Metadata = Aeson.Object
Most configurations do not rely on the internals of this object, so
this should not pose a big problem.
---
title: My first blogpost: Hello world
---
---
title: 'My first blogpost: Hello world'
---
Hakyll will generate a nice error message if you have this problem
anywhere in your posts, so this should be easy to fix.
Let me know if you run into any trouble.
Peace,
Jasper
--
You received this message because you are subscribed to the Google Groups "hakyll" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hakyll+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...