summaryrefslogtreecommitdiff
path: root/app/Main.hs
blob: 1e935e895675d61490f65450df872a22e8550a5b (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
33
34
35
36
37
38
39
40
41
42
43
44
45
module Main where

import Prolog
import Hakyll

import Hakyll.Alias
import Hakyll.Util
import Data.Alias (AliasMap)
import Data.Name (Name_)
import Data.Person (Person_)
import Data.Journal (Journal_)
import Data.License (License_)
import Hakyll.Aeson (yamlCompiler)
import Hakyll.TeX.BibTeX (bibtexCompiler)
import WWW.Base (baseHakyll, domain)
import WWW.Templates (myContext, defaultTemplate)



main :: IO ()
main = baseHakyll domain $ do
    match "templates/**" $ compile templateCompiler
    match "data/*.bib" $ compile bibtexCompiler
    match "data/people.yaml" $ compile $ yamlCompiler @(AliasMap Name_ Person_)
    match "data/licenses.yaml" $ compile $ yamlCompiler @(AliasMap StrictText License_)
    match "data/journals.yaml" $ compile $ yamlCompiler @(AliasMap StrictText Journal_)
    let baseCtxt :: Compiler (Context String)
        baseCtxt = fold <$> sequence
            [ pure myContext
            , personCtxt @StrictText <$> loadBody "data/people.yaml"
            , licenseCtxt @StrictText <$> loadBody "data/licenses.yaml"
            , journalCtxt @StrictText <$> loadBody "data/journals.yaml"
            ]
    match "www/research/index.html" $ do
        route $ dropParentRoute 1
        compile $ do
            papers <- undefined
    match "www/teaching/index.md" $ do
        route $ dropParentRoute 1 `composeRoutes` setExtension ".html"
        compile $ myPandocCompiler >>= applyTemplate defaultTemplate baseCtxt
    pure ()


myPandocCompiler :: Compiler (Item String)
myPandocCompiler = pandocCompilerWith myHakyllReaderOptions myHakyllWriterOptions