hakyll-4.15.1.0: A static website compiler library
Safe HaskellNone
LanguageHaskell2010

Hakyll.Web.Tags

Description

This module containing some specialized functions to deal with tags. It assumes you follow some conventions.

We support two types of tags: tags and categories.

To use default tags, use buildTags. Tags are placed in a comma-separated metadata field like this:

---
author: Philip K. Dick
title: Do androids dream of electric sheep?
tags: future, science fiction, humanoid
---
The novel is set in a post-apocalyptic near future, where the Earth and
its populations have been damaged greatly by Nuclear...

To use categories, use the buildCategories function. Categories are determined by the directory a page is in, for example, the post

posts/coding/2010-01-28-hakyll-categories.markdown

will receive the coding category.

Advanced users may implement custom systems using buildTagsWith if desired.

In the above example, we would want to create a page which lists all pages in the coding category, for example, with the Identifier:

tags/coding.html

This is where the first parameter of buildTags and buildCategories comes in. In the above case, we used the function:

fromCapture "tags/*.html" :: String -> Identifier

The tagsRules function lets you generate such a page for each tag in the Rules monad.

Synopsis

Documentation

data Tags Source #

Data about tags

getTags :: MonadMetadata m => Identifier -> m [String] Source #

Obtain tags from a page in the default way: parse them from the tags metadata field. This can either be a list or a comma-separated string.

getTagsByField :: MonadMetadata m => String -> Identifier -> m [String] Source #

Obtain tags from a page by name of the metadata field. These can be a list or a comma-separated string

getCategory :: MonadMetadata m => Identifier -> m [String] Source #

Obtain category from a page.

buildTagsWith :: MonadMetadata m => (Identifier -> m [String]) -> Pattern -> (String -> Identifier) -> m Tags Source #

Higher-order function to read tags

tagsRules :: Tags -> (String -> Pattern -> Rules ()) -> Rules () Source #

renderTags Source #

Arguments

:: (String -> String -> Int -> Int -> Int -> String)

Produce a tag item: tag, url, count, min count, max count

-> ([String] -> String)

Join items

-> Tags

Tag cloud renderer

-> Compiler String 

Render tags in HTML (the flexible higher-order function)

renderTagCloud Source #

Arguments

:: Double

Smallest font size, in percent

-> Double

Biggest font size, in percent

-> Tags

Input tags

-> Compiler String

Rendered cloud

Render a tag cloud in HTML

renderTagCloudWith Source #

Arguments

:: (Double -> Double -> String -> String -> Int -> Int -> Int -> String)

Render a single tag link

-> ([String] -> String)

Concatenate links

-> Double

Smallest font size, in percent

-> Double

Biggest font size, in percent

-> Tags

Input tags

-> Compiler String

Rendered cloud

Render a tag cloud in HTML

tagCloudField Source #

Arguments

:: String

Destination key

-> Double

Smallest font size, in percent

-> Double

Biggest font size, in percent

-> Tags

Input tags

-> Context a

Context

Render a tag cloud in HTML as a context

tagCloudFieldWith Source #

Arguments

:: String

Destination key

-> (Double -> Double -> String -> String -> Int -> Int -> Int -> String)

Render a single tag link

-> ([String] -> String)

Concatenate links

-> Double

Smallest font size, in percent

-> Double

Biggest font size, in percent

-> Tags

Input tags

-> Context a

Context

Render a tag cloud in HTML as a context

renderTagList :: Tags -> Compiler String Source #

Render a simple tag list in HTML, with the tag count next to the item TODO: Maybe produce a Context here

tagsField Source #

Arguments

:: String

Destination key

-> Tags

Tags

-> Context a

Context

Render tags with links

tagsFieldWith Source #

Arguments

:: (Identifier -> Compiler [String])

Get the tags

-> (String -> Maybe FilePath -> Maybe Html)

Render link for one tag

-> ([Html] -> Html)

Concatenate tag links

-> String

Destination field

-> Tags

Tags structure

-> Context a

Resulting context

Render tags with links with custom functions to get tags and to render links

categoryField Source #

Arguments

:: String

Destination key

-> Tags

Tags

-> Context a

Context

Render the category in a link

sortTagsBy :: ((String, [Identifier]) -> (String, [Identifier]) -> Ordering) -> Tags -> Tags Source #

Sort tags using supplied function. First element of the tuple passed to the comparing function is the actual tag name.

caseInsensitiveTags :: (String, [Identifier]) -> (String, [Identifier]) -> Ordering Source #

Sample sorting function that compares tags case insensitively.