blob: 598f5e2b3dcd25cb1c48de390310cbff9c8fc6df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
module Hakyll.Alias
( aliasCtxt
, personCtxt
) where
import Prolog
import Hakyll
import Data.Alias
import Data.Name
import Data.Person
functionField1 :: String -> (String -> Compiler String) -> Context a
functionField1 n f = functionField n $ \case
[x] -> \_ -> f x
_ -> \_ -> fail $ "Expecting exactly one argument to " <> n
aliasCtxt :: (Ord a, FromAlias a x) => String -> (String -> Compiler a) -> (x -> Compiler String) -> AliasMap a x -> Context c
aliasCtxt name toa fromx amap = functionField1 name $ toa >=> flip resolveAlias amap >=> fromx
personCtxt :: AliasMap Name_ Person_ -> Context a
personCtxt = aliasCtxt "person" (parseName . toSL) (pure . toSL . personHtml)
|