blob: f08c041711128604ac0c5bd14f9f719b8e4f96a9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
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
|