summaryrefslogtreecommitdiff
path: root/src/Hakyll/Core/Target.hs
blob: b8740bc29f8f927ad614648e3b51d7e421bff1d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
-- | A target represents one compilation unit, e.g. a blog post, a CSS file...
--
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Hakyll.Core.Target
    ( DependencyLookup
    , TargetM
    , Target
    , runTarget
    , getIdentifier
    , getResourceString
    ) where

import Control.Applicative ((<$>))
import Control.Monad.Reader (ask)
import Control.Monad.Trans (liftIO)

import Hakyll.Core.Identifier
import Hakyll.Core.Target.Internal
import Hakyll.Core.ResourceProvider

-- | Get the current identifier
--
getIdentifier :: TargetM a Identifier
getIdentifier = TargetM $ targetIdentifier <$> ask

-- | Get the resource content as a string
--
getResourceString :: TargetM a String
getResourceString = TargetM $ do
    provider <- targetResourceProvider <$> ask
    identifier <- unTargetM getIdentifier
    liftIO $ resourceString provider identifier