diff options
| author | Chris Wells <chris@mathematicaster.org> | 2025-02-10 12:48:38 -0600 |
|---|---|---|
| committer | Chris Wells <chris@mathematicaster.org> | 2025-02-10 12:48:38 -0600 |
| commit | 0c677070edf9978cb85a0b521f7e6e0ef6d6b491 (patch) | |
| tree | 1bf0a024ea2c1ccc9c21c68b916e76017bafd310 /src/Hakyll/Alias.hs | |
| parent | 75ac829ee7d661d758f7828e609e28ee4e05d038 (diff) | |
| download | main-0c677070edf9978cb85a0b521f7e6e0ef6d6b491.tar main-0c677070edf9978cb85a0b521f7e6e0ef6d6b491.tar.gz main-0c677070edf9978cb85a0b521f7e6e0ef6d6b491.tar.bz2 main-0c677070edf9978cb85a0b521f7e6e0ef6d6b491.tar.lz main-0c677070edf9978cb85a0b521f7e6e0ef6d6b491.tar.xz main-0c677070edf9978cb85a0b521f7e6e0ef6d6b491.tar.zst main-0c677070edf9978cb85a0b521f7e6e0ef6d6b491.zip | |
A lot of work on aliases and the like
Diffstat (limited to 'src/Hakyll/Alias.hs')
| -rw-r--r-- | src/Hakyll/Alias.hs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/Hakyll/Alias.hs b/src/Hakyll/Alias.hs new file mode 100644 index 0000000..598f5e2 --- /dev/null +++ b/src/Hakyll/Alias.hs @@ -0,0 +1,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) |
