summaryrefslogtreecommitdiff
path: root/src/Hakyll/Core/ResourceProvider/FileResourceProvider.hs
blob: a2376c215bb654635dd4a8e6ff106904019464f7 (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
-- | A concrete 'ResourceProvider' that gets it's resources from the filesystem
--
module Hakyll.Core.ResourceProvider.FileResourceProvider
    ( fileResourceProvider
    ) where

import Control.Applicative ((<$>))

import qualified Data.ByteString.Lazy as LB

import Hakyll.Core.ResourceProvider
import Hakyll.Core.Identifier
import Hakyll.Core.Util.File

-- | Create a filesystem-based 'ResourceProvider'
--
fileResourceProvider :: IO ResourceProvider
fileResourceProvider = do
    list <- map parseIdentifier <$> getRecursiveContents "."
    return ResourceProvider
        { resourceList           = list
        , resourceString         = readFile . toFilePath
        , resourceLazyByteString = LB.readFile . toFilePath
        }