hakyll-3.2.0.3: A static website compiler library

Hakyll.Web.Page.Metadata

Description

Provides various functions to manipulate the metadata fields of a page

Synopsis

Documentation

getFieldSource

Arguments

:: String

Key

-> Page a

Page

-> String

Value

Get a metadata field. If the field does not exist, the empty string is returned.

getFieldMaybeSource

Arguments

:: String

Key

-> Page a

Page

-> Maybe String

Value, if found

Get a field in a Maybe wrapper

setFieldSource

Arguments

:: String

Key

-> String

Value

-> Page a

Page to add it to

-> Page a

Resulting page

Version of trySetField which overrides any previous value

trySetFieldSource

Arguments

:: String

Key

-> String

Value

-> Page a

Page to add it to

-> Page a

Resulting page

Add a metadata field. If the field already exists, it is not overwritten.

setFieldASource

Arguments

:: Arrow a 
=> String

Key

-> a x String

Value arrow

-> a (Page b, x) (Page b)

Resulting arrow

Arrow-based variant of setField. Because of it's type, this function is very usable together with the different require functions.

setFieldPageSource

Arguments

:: String

Key to add the page under

-> Identifier (Page String)

Page to add

-> Compiler (Page a) (Page a)

Page compiler

Set a field of a page to the contents of another page

renderFieldSource

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

-> Page a

Page on which this should be applied

-> Page a

Resulting page

Do something with a metadata value, but keep the old value as well. If the key given is not present in the metadata, nothing will happen. If the source and destination keys are the same, the value will be changed (but you should use changeField for this purpose).

changeFieldSource

Arguments

:: String

Key to change.

-> (String -> String)

Function to apply on the value.

-> Page a

Page to change

-> Page a

Resulting page

Change a metadata value.

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

Will put the title in UPPERCASE.

copyFieldSource

Arguments

:: String

Key to copy

-> String

Destination to copy to

-> Page a

Page on which this should be applied

-> Page a

Resulting page

Make a copy of a metadata field (put the value belonging to a certain key under some other key as well)

renderDateFieldSource

Arguments

:: String

Key in which the rendered date should be placed

-> String

Format to use on the date

-> String

Default value, in case the date cannot be parsed

-> Page a

Page on which this should be applied

-> Page a

Resulting page

When the metadata has a field 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.

renderDateFieldWithSource

Arguments

:: TimeLocale

Output time locale

-> String

Destination key

-> String

Format to use on the date

-> String

Default value

-> Page a

Target page

-> Page a

Resulting page

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

copyBodyToFieldSource

Arguments

:: String

Destination key

-> Page String

Target page

-> Page String

Resulting page

Copy the body of a page to a metadata field

copyBodyFromFieldSource

Arguments

:: String

Source key

-> Page String

Target page

-> Page String

Resulting page

Copy a metadata field to the page body