{-# LANGUAGE AllowAmbiguousTypes   #-}
{-# LANGUAGE FlexibleInstances     #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes            #-}
{-# LANGUAGE ScopedTypeVariables   #-}
{-# LANGUAGE TypeApplications      #-}
{-# LANGUAGE TypeSynonymInstances  #-}

module Hakyll.Ogmarkup
  ( ogmarkupCompile
  , ogmarkupCompile'
  ) where

import           Data.Proxy    (Proxy)
import           Hakyll
import           Text.Ogmarkup

-- | A Hakyll compiler used to build an output data which is determined by
-- the ogmarkup configuration passed as argument.
ogmarkupCompile :: forall c o.
                   (GenConf c o)
                => Compiler (Item o)
ogmarkupCompile = getResourceBody >>= withItemBody (return . ogmarkup @c)

ogmarkupCompile' :: forall c o.
                    (GenConf c o)
                 => Proxy c
                 -> Compiler (Item o)
ogmarkupCompile' _ = ogmarkupCompile @c