pencil-1.0.0: Static site generator

Safe HaskellNone
LanguageHaskell2010

Pencil.Config

Description

Pencil Config.

Synopsis

Documentation

data Config Source #

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.

Instances
Default Config Source # 
Instance details

Defined in Pencil.Config

Methods

def :: Config #

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.

setEnv :: Env -> Config -> Config Source #

Sets the current environment. You may also want to look at withEnv if you want to render things in a modified environment.

updateEnv :: (Env -> Env) -> Config -> Config Source #

Updates the Env inside the Config.

getDisplayValue :: Config -> Value -> Text Source #

Gets the function that renders Value to text.

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 Values 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.