module Hakyll.Web.Template.Util ( 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