summaryrefslogtreecommitdiff
path: root/src/Hakyll/Alias.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Hakyll/Alias.hs')
-rw-r--r--src/Hakyll/Alias.hs23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/Hakyll/Alias.hs b/src/Hakyll/Alias.hs
index 063ea2b..33ed5c1 100644
--- a/src/Hakyll/Alias.hs
+++ b/src/Hakyll/Alias.hs
@@ -20,12 +20,23 @@ import Hakyll.Web.Template.Util (functionField1)
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
+aliasCtxtFrom :: (Ord a, FromAlias a x) => String -> (String -> Compiler a) -> (x -> Compiler String) -> Identifier -> Context c
+aliasCtxtFrom name toa fromx ident = functionField1 name $ \s -> do
+ amap <- loadBody ident
+ toa s >>= flip resolveAlias amap >>= fromx
-personCtxt :: (StringConv StrictText s, Ord (Name s), ToMarkup s) => AliasMap (Name s) (Person s) -> Context a
-personCtxt = aliasCtxt "personA" (ffmap toSL . parseName . toSL) (pure . toSL . personHtml)
-licenseCtxt :: (StringConv String s, Ord s, ToMarkup s) => AliasMap s (License s) -> Context a
-licenseCtxt = aliasCtxt "licenseA" (pure . toSL) (pure . toSL . licenseHtml)
+-- personCtxt :: (StringConv StrictText s, Ord (Name s), ToMarkup s) => AliasMap (Name s) (Person s) -> Context a
+personCtxt :: Identifier -> Context a
+personCtxt = aliasCtxtFrom @StrictText "personA" (ffmap toSL . parseName . toSL) (pure . toSL . personHtml)
-journalCtxt :: (StringConv String s, Ord s, ToMarkup s) => AliasMap s (Journal s) -> Context a
-journalCtxt = aliasCtxt "journalA" (pure . toSL) (pure . toSL . journalHtml)
+-- personCtxtFrom :: Identifier -> Context a
+-- personCtxtFrom = functionField1
+
+-- licenseCtxt :: (StringConv String s, Ord s, ToMarkup s) => AliasMap s (License s) -> Context a
+licenseCtxt :: Identifier -> Context a
+licenseCtxt = aliasCtxtFrom @StrictText "licenseA" (pure . toSL) (pure . toSL . licenseHtml)
+
+-- journalCtxt :: (StringConv String s, Ord s, ToMarkup s) => AliasMap s (Journal s) -> Context a
+journalCtxt :: Identifier -> Context a
+journalCtxt = aliasCtxtFrom @StrictText "journalA" (pure . toSL) (pure . toSL . journalHtml)