Text.Hakyll.ContextManipulations
Description
This module exports a number of functions that produce HakyllActions to
manipulate Contexts.
- renderValue :: String -> String -> (String -> String) -> HakyllAction Context Context
- changeValue :: String -> (String -> String) -> HakyllAction Context Context
- changeUrl :: (String -> String) -> HakyllAction Context Context
- copyValue :: String -> String -> HakyllAction Context Context
- renderDate :: String -> String -> String -> HakyllAction Context Context
- renderDateWithLocale :: TimeLocale -> String -> String -> String -> HakyllAction Context Context
- changeExtension :: String -> HakyllAction Context Context
- renderBody :: (String -> String) -> HakyllAction Context Context
- takeBody :: HakyllAction Context String
Documentation
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.
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.
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.
Arguments
| :: String | Source key. |
| -> String | Destination key. |
| -> HakyllAction Context Context |
Copy a value from one key to another in a Context.
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.
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.
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.
takeBody :: HakyllAction Context StringSource
Get the resulting body text from a context