-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsite.hs
70 lines (56 loc) · 2.24 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Monad (liftM)
import Data.Default (def)
import Data.Monoid (mappend, mconcat, mempty)
import Hakyll
import Hakyll.Core.Identifier.Pattern (Pattern (..))
import Hakyll.Web.Sass
import Text.Pandoc.Options
import Text.Pandoc
bibFile, cslFile :: String
bibFile = "bibliography.bib"
cslFile = "theme/citstyle.csl"
main :: IO ()
main = hakyll $ do
match (fromGlob bibFile) $ compile biblioCompiler
match (fromGlob cslFile) $ compile cslCompiler
match "haskell.org" $ do
route $ customRoute $ const "index.html"
compile $
bibtexCompiler cslFile bibFile >>=
loadAndApplyTemplate "theme/tpl/default.html" defaultContext >>=
relativizeUrls
match "theme/scss/theme.scss" $ do
route $ gsubRoute "theme/scss/" (const "theme/") `composeRoutes` setExtension "css"
compile $ sassCompilerWith def {
sassOutputStyle = SassStyleCompressed -- SassStyleCompact
}
match ("theme/img/*" .||. "theme/js/*") $ do
route idRoute
compile copyFileCompiler
match "theme/tpl/*" $ compile templateCompiler
bibtexCompiler :: String -> String -> Compiler (Item String)
bibtexCompiler cslFileName bibFileName = do
csl <- load $ fromFilePath cslFileName
bib <- load $ fromFilePath bibFileName
liftM (writePandocWith myWriterOptions)
(getResourceBody >>= readPandocBiblio myReaderOptions csl bib)
where
myReaderOptions :: ReaderOptions
myReaderOptions = def {
readerParseRaw = True,
readerSmart = True }
myWriterOptions :: WriterOptions
myWriterOptions = def { writerSectionDivs = True,
writerHtml5 = True,
writerHighlight = True,
writerHTMLMathMethod = Text.Pandoc.MathML Nothing,
writerEmailObfuscation = NoObfuscation }
-- bibtexCompiler = do
-- csl <- load "theme/iso690-author-date-fr.csl"
-- bib <- load "bibliography.bib"
-- getResourceBody
-- >>= readPandocBiblio def csl bib
-- >>= return . writePandoc
--