rauhala.info/site/app/site.hs

55 lines
1.3 KiB
Haskell
Raw Normal View History

2018-09-20 20:58:27 +03:00
--------------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
2021-01-25 19:29:45 +02:00
import Hakyll
import Data.List
2021-01-25 19:35:21 +02:00
(isPrefixOf, isSuffixOf)
import System.FilePath
(takeFileName)
2018-09-20 20:58:27 +03:00
--------------------------------------------------------------------------------
main :: IO ()
2021-01-25 19:35:21 +02:00
main = hakyllWith defaultConfiguration{ignoreFile = ignore} $ do
2021-01-25 19:29:45 +02:00
match "well-known/*" $ do
route (customRoute (prepend '.'. toFilePath))
compile copyFileCompiler
2020-02-01 22:25:52 +02:00
2021-01-25 19:29:45 +02:00
match "images/*" $ do
route idRoute
compile copyFileCompiler
2018-09-20 20:58:27 +03:00
2021-01-25 19:29:45 +02:00
match "resources/*" $ do
route idRoute
compile copyFileCompiler
2018-09-20 20:58:27 +03:00
2021-01-25 19:29:45 +02:00
match "css/*" $ do
route idRoute
compile compressCssCompiler
2018-09-20 20:58:27 +03:00
2021-01-25 19:29:45 +02:00
match "js/*" $ do
route idRoute
compile compressCssCompiler
2018-09-20 22:23:57 +03:00
2021-01-25 19:29:45 +02:00
match (fromList ["index.markdown", "contact.markdown"]) $ do
route $ setExtension "html"
compile $ pandocCompiler
>>= loadAndApplyTemplate "templates/default.html" defaultContext
>>= relativizeUrls
2018-09-20 20:58:27 +03:00
2021-01-25 19:29:45 +02:00
match "templates/*" $ compile templateBodyCompiler
2021-01-25 19:35:21 +02:00
where
ignore path = any ($ takeFileName path)
[ ("." `isPrefixOf`)
, ("#" `isPrefixOf`)
, ("~" `isSuffixOf`)
, (".swp" `isSuffixOf`)
]
2018-09-20 20:58:27 +03:00
2020-02-01 22:25:52 +02:00
prepend :: a -> [a] -> [a]
prepend = (:)