@@ -0,0 +1,55 @@
1+-- | A module dealing with common file extensions and associated file types.
3+module Hakyll.Web.FileType
9+import System.FilePath (takeExtension)
10+import Control.Applicative ((<$>))
12+import Hakyll.Core.Identifier
13+import Hakyll.Core.Target
15+-- | Datatype to represent the different file types Hakyll can deal with by
21+ | LiterateHaskell FileType
27+ deriving (Eq, Ord, Show, Read)
29+-- | Get the file type for a certain file. The type is determined by extension.
31+fileType :: FilePath -> FileType
32+fileType = fileType' . takeExtension
34+ fileType' ".htm" = Html
35+ fileType' ".html" = Html
36+ fileType' ".lhs" = LiterateHaskell Markdown
37+ fileType' ".markdown" = Markdown
38+ fileType' ".md" = Markdown
39+ fileType' ".mdn" = Markdown
40+ fileType' ".mdown" = Markdown
41+ fileType' ".mdwn" = Markdown
42+ fileType' ".mkd" = Markdown
43+ fileType' ".mkdwn" = Markdown
44+ fileType' ".page" = Markdown
45+ fileType' ".rst" = ReStructuredText
46+ fileType' ".tex" = LaTeX
47+ fileType' ".text" = PlainText
48+ fileType' ".txt" = PlainText
49+ fileType' ".css" = Css
50+ fileType' _ = UnknownFileType
52+-- | Get the file type for the current file
54+getFileType :: TargetM a FileType
55+getFileType = fileType . toFilePath <$> getIdentifier