Copyright | Copyright (C) 2023 Yoo Chung |
---|---|
License | All rights reserved |
Maintainer | web@chungyc.org |
Safe Haskell | Safe-Inferred |
Language | GHC2021 |
Web.Site.Compilers
Description
Various Hakyll compilers and functions to assist use of Hakyll compilers.
Synopsis
- haskellCompiler :: [String] -> Compiler (Item ByteString)
- mathReaderOptions :: ReaderOptions
- mathWriterOptions :: WriterOptions
- getTocOptionsWith :: WriterOptions -> Compiler WriterOptions
- siteContext :: Context String
- cleanupIndexUrl :: String -> String
Compilers
Arguments
:: [String] | Extra flags to pass to |
-> Compiler (Item ByteString) |
Run the Haskell code in the underlying file and use its output.
For example,
>>>
let _ = compile $ haskellCompiler []
The Haskell code will be executed using runhaskell
.
It will run with -XGHC2021
and -XOverloadedStrings
.
Extra flags can also be passed to runhaskell
.
For example,
>>>
let _ = compile $ haskellCompiler ["-XTypeFamilies"]
This can compile both Haskell code and literate Haskell code.
Pandoc options
Pandoc reader and writer options that can be used with pandocCompilerWith
.
mathReaderOptions :: ReaderOptions Source #
Reader options for properly treating math in input.
Should be used in conjunction with mathWriterOptions
for proper math rendering.
For example:
>>>
let _ = pandocCompilerWith mathReaderOptions mathWriterOptions
mathWriterOptions :: WriterOptions Source #
Writer options for writing out math to HTML.
Should be used in conjunction with mathReaderOptions
to read input that is to be rendered as math.
For example:
>>>
let _ = pandocCompilerWith mathReaderOptions mathWriterOptions
Pages which use math should define the include-math
metadata field
to ensure that the resources necessary for rendering math is included.
getTocOptionsWith :: WriterOptions -> Compiler WriterOptions Source #
Rewrite the writer options to include a table of contents
if the source has a toc
field in its metadata.
If there is no such field, the given writer options are returned as is.
For example:
>>>
let _ = getTocOptionsWith defaultHakyllWriterOptions
>>>
let _ = getTocOptionsWith mathWriterOptions
Custom contexts
siteContext :: Context String Source #
Default context used for the site. Adds customizations specific to this site to "defaultContext". In particular,
- Cleans
index.html
URLs into directory URLs ending with/
.
Use this when compiling items for this site instead of "defaultContext".
Utilities
cleanupIndexUrl :: String -> String Source #
If the given URL is local and ends with index.html
, strip the latter.
For example:
>>>
cleanupIndexUrl "/article/index.html"
"/article/">>>
cleanupIndexUrl "/article/page.html"
"/article/page.html">>>
cleanupIndexUrl "http://chungyc.org/article/index.html"
"http://chungyc.org/article/index.html"
URLs are cleaned up by default with "siteContext", so one will usually not call this directly.