hakyll-2.2.2: A simple static site generator library.

Text.Hakyll.ContextManipulations

Description

This module exports a number of functions that produce HakyllActions to manipulate Contexts.

Synopsis

Documentation

renderValueSource

Arguments

:: String

Key of which the value should be copied.

-> String

Key the value should be copied to.

-> (String -> String)

Function to apply on the value.

-> HakyllAction Context Context 

Do something with a value in a Context, but keep the old value as well. If the key given is not present in the Context, nothing will happen.

changeValueSource

Arguments

:: String

Key to change.

-> (String -> String)

Function to apply on the value.

-> HakyllAction Context Context 

Change a value in a Context.

 import Data.Char (toUpper)
 changeValue "title" (map toUpper)

Will put the title in UPPERCASE.

changeUrlSource

Arguments

:: (String -> String)

Function to change URL with.

-> HakyllAction Context Context

Resulting action.

Change the URL of a page. This requires a special function, so dependency handling can happen correctly.

copyValueSource

Arguments

:: String

Source key.

-> String

Destination key.

-> HakyllAction Context Context 

Copy a value from one key to another in a Context.

renderDateSource

Arguments

:: String

Key in which the rendered date should be placed.

-> String

Format to use on the date.

-> String

Default key, in case the date cannot be parsed.

-> HakyllAction Context Context 

When the context has a key called path in a folder/yyyy-mm-dd-title.extension format (the convention for pages), this function can render the date.

 renderDate "date" "%B %e, %Y" "Date unknown"

Will render something like January 32, 2010.

renderDateWithLocaleSource

Arguments

:: TimeLocale

Output time locale.

-> String

Destination key.

-> String

Format to use on the date.

-> String

Default key.

-> HakyllAction Context Context 

This is an extended version of renderDate that allows you to specify a time locale that is used for outputting the date. For more details, see renderDate.

changeExtensionSource

Arguments

:: String

Extension to change to.

-> HakyllAction Context Context 

Change the extension of a file. This is only needed when you want to render, for example, mardown to .php files instead of .html files.

 changeExtension "php"

Will render test.markdown to test.php instead of test.html.

renderBody :: (String -> String) -> HakyllAction Context ContextSource

Change the body of a file using a certain manipulation.

 import Data.Char (toUpper)
 renderBody (map toUpper)

Will put the entire body of the page in UPPERCASE.