From e914e77f87a51c25141ab297d11344118a6f6e20 Mon Sep 17 00:00:00 2001 From: Chris Wells Date: Tue, 11 Feb 2025 14:47:40 -0600 Subject: Working on aliases --- src/Hakyll/Web/Template/Util.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/Hakyll/Web/Template') diff --git a/src/Hakyll/Web/Template/Util.hs b/src/Hakyll/Web/Template/Util.hs index cfd8573..f08c041 100644 --- a/src/Hakyll/Web/Template/Util.hs +++ b/src/Hakyll/Web/Template/Util.hs @@ -1,11 +1,18 @@ module Hakyll.Web.Template.Util - ( slug + ( functionField1 + , slug ) where import Prolog +import Hakyll import Hakyll.Web.Template.Context import Data.String.Slugger +import System.FilePath +functionField1 :: String -> (String -> Compiler String) -> Context a +functionField1 n f = functionField n $ \case + [x] -> \_ -> f x + xs -> \_ -> fail $ "Expecting exactly one argument to " <> n <> ". Instead got " <> show (length xs) slug :: Context a slug = functionField "slug" $ \strs _ -> pure $ toSlug $ unwords strs -- cgit v1.2.3