module Hakyll.Web.Meta.OpenGraph
( openGraphField
) where
import Hakyll.Core.Compiler
import Hakyll.Core.Item
import Hakyll.Web.Template
import Hakyll.Web.Template.Context
openGraphField :: String -> Context String -> Context String
openGraphField :: String -> Context String -> Context String
openGraphField String
k Context String
ctx = forall a.
String -> ([String] -> Item a -> Compiler String) -> Context a
functionField String
k forall a b. (a -> b) -> a -> b
$ \[String]
_args Item String
i -> do
Template
template <- Compiler Template
openGraphTemplate
forall a. Item a -> a
itemBody forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Template -> Context a -> Item a -> Compiler (Item String)
applyTemplate Template
template Context String
ctx Item String
i
openGraphTemplate :: Compiler Template
openGraphTemplate :: Compiler Template
openGraphTemplate = do
forall a. a -> Compiler (Item a)
makeItem String
openGraphTemplateString forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Item String -> Compiler Template
compileTemplateItem
openGraphTemplateString :: String
openGraphTemplateString :: String
openGraphTemplateString =
String
"<meta property=\"og:type\" content=\"article\" />\
\<meta property=\"og:url\" content=\"$root$$url$\" />\
\<meta property=\"og:title\" content=\"$title$\" />\
\$if(og-description)$\
\<meta property=\"og:description\" content=\"$og-description$\" />\
\$endif$\
\$if(og-image)$\
\<meta property=\"og:image\" content=\"$og-image$\" />\
\$endif$\
\"