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.hs20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/Hakyll/Alias.hs b/src/Hakyll/Alias.hs
index 598f5e2..4284e3d 100644
--- a/src/Hakyll/Alias.hs
+++ b/src/Hakyll/Alias.hs
@@ -1,6 +1,8 @@
module Hakyll.Alias
( aliasCtxt
, personCtxt
+ , licenseCtxt
+ , journalCtxt
) where
import Prolog
@@ -8,16 +10,22 @@ import Hakyll
import Data.Alias
import Data.Name
import Data.Person
+import Data.Journal
+import Data.License
+import Text.Blaze
+import Hakyll.Web.Template.Util (functionField1)
-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)
+personCtxt :: (StringConv StrictText s, Ord (Name s), ToMarkup s) => AliasMap (Name s) (Person s) -> Context a
+personCtxt = aliasCtxt "person" (fmap (fmap toSL) . parseName . toSL) (pure . toSL . personHtml)
+
+licenseCtxt :: (StringConv String s, Ord s, ToMarkup s) => AliasMap s (License s) -> Context a
+licenseCtxt = aliasCtxt "license" (pure . toSL) (pure . toSL . licenseHtml)
+
+journalCtxt :: (StringConv String s, Ord s, ToMarkup s) => AliasMap s (Journal s) -> Context a
+journalCtxt = aliasCtxt "journal" (pure . toSL) (pure . toSL . journalHtml)