Safe Haskell | None |
---|---|
Language | Haskell2010 |
Pencil Config.
Synopsis
- data Config = Config {}
- defaultConfig :: Config
- getSourceDir :: Config -> FilePath
- setSourceDir :: FilePath -> Config -> Config
- getOutputDir :: Config -> FilePath
- setOutputDir :: FilePath -> Config -> Config
- getEnv :: Config -> Env
- setEnv :: Env -> Config -> Config
- updateEnv :: (Env -> Env) -> Config -> Config
- getDisplayValue :: Config -> Value -> Text
- setDisplayValue :: (Value -> Text) -> Config -> Config
- getSassOptions :: Config -> SassOptions
- setSassOptions :: SassOptions -> Config -> Config
- getPandocReaderOptions :: Config -> ReaderOptions
- setPandocReaderOptions :: ReaderOptions -> Config -> Config
- getPandocWriterOptions :: Config -> WriterOptions
- setPandocWriterOptions :: WriterOptions -> Config -> Config
Documentation
The main Config
needed to build your website. Your app's Config
is
passed into the PencilApp
monad transformer.
Use defaultConfig
as a starting point, along with the config-modification
helpers such as setSourceDir
.
defaultConfig :: Config Source #
This default Config
gives you everything you need to start.
Default values:
Config {configSourceDir
= "site/" ,configOutputDir
= "out/" ,configEnv
= HashMap.empty ,configDisplayValue
=toText
,configSassOptions
= Text.Sass.Options.defaultSassOptions ,configPandocReaderOptions
= Text.Pandoc.def { Text.Pandoc.readerExtensions =disableExtension
Ext_tex_math_dollars
(getDefaultExtensions
"markdown") } ,configPandocWriterOptions
= Text.Pandoc.def { Text.Pandoc.writerHighlightStyle = Just Text.Pandoc.Highlighting.monochrome } , 'configDisplayValue =toText
}
Ext_tex_math_dollars
is disabled because it messes with parsing template
variable directives. If you want TeX math, the better option is drop in a
JavaScript library like KaTeX (https://katex.org).
getSourceDir :: Config -> FilePath Source #
Gets the source directory of your web page source files.
setSourceDir :: FilePath -> Config -> Config Source #
Sets the source directory of your web page source files.
getOutputDir :: Config -> FilePath Source #
Gets the output directory of your rendered web pages.
setOutputDir :: FilePath -> Config -> Config Source #
Sets the output directory of your rendered web pages.
getEnv :: Config -> Env Source #
Gets environment of the Config
, which is what the PencilApp
monad
transformer uses. This is where variables are set for rendering template
directives.
setDisplayValue :: (Value -> Text) -> Config -> Config Source #
Sets the function that renders Value
to text. Overwrite this with your
own function if you would like to change how certain Value
s are rendered
(e.g. VDateTime
).
myRender :: Value -> T.Text myRender (VDateTime dt) =pack
$formatTime
defaultTimeLocale
"%e %B %Y" dt myRender t =toText
t ... setDisplayValue myRender config
In the above example, we change the VDateTime
rendering to show 25
December 2017
. Leave everything else unchanged.
getSassOptions :: Config -> SassOptions Source #
Gets the SassOptions
for rendering Sass/Scss files.
setSassOptions :: SassOptions -> Config -> Config Source #
Sets the SassOptions
for rendering Sass/Scss files.
getPandocReaderOptions :: Config -> ReaderOptions Source #
Gets the ReaderOptions
for reading files that use Pandoc.
Supported formats:
- Markdown
- Open a GitHub issue if you'd like to see more options!
setPandocReaderOptions :: ReaderOptions -> Config -> Config Source #
Sets the ReaderOptions
. For example, you may want to enable
some Pandoc extensions like Ext_literate_haskell
:
setPandocReaderOptions
(Text.Pandoc.def { readerExtensions
= extensionsFromList [Ext_literate_haskell] })
config
getPandocWriterOptions :: Config -> WriterOptions Source #
Gets the WriterOptions
for rendering files that use Pandoc.
setPandocWriterOptions :: WriterOptions -> Config -> Config Source #
Sets the WriterOptions
.