-
Notifications
You must be signed in to change notification settings - Fork 0
/
site.hs
39 lines (31 loc) · 1.08 KB
/
site.hs
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
33
34
35
36
37
38
39
import Hakyll
import Hakyll.Web.Sass
import System.FilePath.Posix (takeBaseName, takeDirectory, (</>))
-- Moves from `/path/to/source.ext` to `/path/to/source/index.html`
-- This way the page can be accessed by `website.tld/path/to/source` without any extension
cleanRoute :: Routes
cleanRoute = customRoute createIndexRoute
where
createIndexRoute ident = takeDirectory p </> takeBaseName p </> "index.html"
where p = toFilePath ident
myCompiler = do
getResourceBody
>>= loadAndApplyTemplate "template.html" defaultContext
>>= relativizeUrls
main :: IO ()
main = hakyllWith config $ do
match "template.html" $ compile templateBodyCompiler
match "static/**" $ do
route idRoute
compile copyFileCompiler
match "style.scss" $ do
route $ setExtension "css"
compile $ (compressCss <$>) <$> sassCompiler
match "index.html" $ do
route $ idRoute
compile $ myCompiler
match "*.html" $ do
route $ cleanRoute
compile $ myCompiler
config :: Configuration
config = defaultConfiguration { providerDirectory = "src" }