54
src/Main.hs
54
src/Main.hs
@@ -6,11 +6,13 @@ import Data.Maybe (isJust)
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
import Hakyll
|
||||
import System.Environment (getEnv)
|
||||
import System.FilePath (replaceDirectory, replaceExtension, takeDirectory)
|
||||
import System.IO.Unsafe (unsafePerformIO)
|
||||
import qualified System.Process as Process
|
||||
import Text.Pandoc
|
||||
( WriterOptions
|
||||
( writerHighlightStyle,
|
||||
import Text.Pandoc (
|
||||
WriterOptions (
|
||||
writerHighlightStyle,
|
||||
writerNumberSections,
|
||||
writerTOCDepth,
|
||||
writerTableOfContents,
|
||||
@@ -19,8 +21,6 @@ import Text.Pandoc
|
||||
)
|
||||
import qualified Text.Pandoc as Pandoc
|
||||
import Text.Pandoc.Templates (Template, compileTemplate)
|
||||
import System.Environment (getEnv)
|
||||
import System.IO.Unsafe (unsafePerformIO)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@@ -162,13 +162,13 @@ main = hakyllWith config $ do
|
||||
_ <-
|
||||
Process.system $
|
||||
unwords
|
||||
[ "xelatex",
|
||||
"-halt-on-error",
|
||||
"-output-directory",
|
||||
tmpDir,
|
||||
texPath,
|
||||
">/dev/null",
|
||||
"2>&1"
|
||||
[ "xelatex"
|
||||
, "-halt-on-error"
|
||||
, "-output-directory"
|
||||
, tmpDir
|
||||
, texPath
|
||||
, ">/dev/null"
|
||||
, "2>&1"
|
||||
]
|
||||
return ()
|
||||
|
||||
@@ -177,18 +177,18 @@ main = hakyllWith config $ do
|
||||
rssFeedConfiguration :: FeedConfiguration
|
||||
rssFeedConfiguration =
|
||||
FeedConfiguration
|
||||
{ feedTitle = "nattopages",
|
||||
feedDescription = "Pages by natto",
|
||||
feedAuthorName = "Amneesh Singh",
|
||||
feedAuthorEmail = "natto@weirdnatto.in",
|
||||
feedRoot = "https://weirdnatto.in"
|
||||
{ feedTitle = "nattopages"
|
||||
, feedDescription = "Pages by natto"
|
||||
, feedAuthorName = "Amneesh Singh"
|
||||
, feedAuthorEmail = "natto@weirdnatto.in"
|
||||
, feedRoot = "https://weirdnatto.in"
|
||||
}
|
||||
|
||||
config :: Configuration
|
||||
config =
|
||||
defaultConfiguration
|
||||
{ deployCommand = "rsync --checksum -ave 'ssh -p" ++ sshTargetPort ++"' _site/* " ++ sshTarget,
|
||||
previewPort = 3333
|
||||
{ deployCommand = "rsync --checksum -ave 'ssh -p" ++ sshTargetPort ++ "' _site/* " ++ sshTarget
|
||||
, previewPort = 3333
|
||||
}
|
||||
where
|
||||
{-# NOINLINE sshTarget #-}
|
||||
@@ -228,18 +228,18 @@ defaultCtx =
|
||||
writerOptions :: Bool -> WriterOptions
|
||||
writerOptions withNumbering =
|
||||
defaultHakyllWriterOptions
|
||||
{ writerNumberSections = withNumbering,
|
||||
writerTableOfContents = True,
|
||||
writerTOCDepth = 2,
|
||||
writerTemplate = Just tocTemplate
|
||||
{ writerNumberSections = withNumbering
|
||||
, writerTableOfContents = True
|
||||
, writerTOCDepth = 2
|
||||
, writerTemplate = Just tocTemplate
|
||||
}
|
||||
|
||||
tocTemplate :: Text.Pandoc.Templates.Template Text
|
||||
tocTemplate =
|
||||
either error id . runIdentity . compileTemplate "" $
|
||||
T.unlines
|
||||
[ "<div class=\"toc\"><div class=\"toc-header\">Table of Contents</div>",
|
||||
"$toc$",
|
||||
"</div>",
|
||||
"$body$"
|
||||
[ "<div class=\"toc\"><div class=\"toc-header\">Table of Contents</div>"
|
||||
, "$toc$"
|
||||
, "</div>"
|
||||
, "$body$"
|
||||
]
|
||||
|
Reference in New Issue
Block a user