Safe Haskell | None |
---|
Module containing some specialized functions to deal with tags. This Module follows certain conventions. My advice is to stick with them if possible.
More concrete: all functions in this module assume that the tags are
located in the tags
field, and separated by commas. An example file
foo.markdown
could look like:
--- 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...
All the following functions would work with such a format. In addition to tags, Hakyll also supports categories. The convention when using categories is to place pages in subdirectories.
An example, the page posts/coding/2010-01-28-hakyll-categories.markdown
Tags or categories are read using the readTags
and readCategory
functions. This module only provides functions to work with tags:
categories are represented as tags. This is perfectly possible: categories
only have an additional restriction that a page can only have one category
(instead of multiple tags).
- data Tags a = Tags {}
- getTags :: Page a -> [String]
- readTagsWith :: (Page a -> [String]) -> [Page a] -> Tags a
- readTags :: [Page a] -> Tags a
- readCategory :: [Page a] -> Tags a
- renderTagCloud :: (String -> Identifier (Page a)) -> Double -> Double -> Compiler (Tags a) String
- renderTagList :: (String -> Identifier (Page a)) -> Compiler (Tags a) String
- renderTagsField :: String -> (String -> Identifier a) -> Compiler (Page a) (Page a)
- renderTagsFieldWith :: (Page a -> [String]) -> String -> (String -> Identifier a) -> Compiler (Page a) (Page a)
- renderCategoryField :: String -> (String -> Identifier a) -> Compiler (Page a) (Page a)
- sortTagsBy :: ((String, [Page a]) -> (String, [Page a]) -> Ordering) -> Compiler (Tags a) (Tags a)
- caseInsensitiveTags :: (String, [Page a]) -> (String, [Page a]) -> Ordering
Documentation
Data about tags
getTags :: Page a -> [String]Source
Obtain tags from a page in the default way: parse them from the tags
metadata field.
:: (Page a -> [String]) | Function extracting tags from a page |
-> [Page a] | Pages |
-> Tags a | Resulting tags |
Higher-level function to read tags
readCategory :: [Page a] -> Tags aSource
Read a tagmap using the category
metadata field
:: (String -> Identifier (Page a)) | Produce a link for a tag |
-> Double | Smallest font size, in percent |
-> Double | Biggest font size, in percent |
-> Compiler (Tags a) String | Tag cloud renderer |
Render a tag cloud in HTML
renderTagList :: (String -> Identifier (Page a)) -> Compiler (Tags a) StringSource
Render a simple tag list in HTML, with the tag count next to the item
:: String | Destination key |
-> (String -> Identifier a) | Create a link for a tag |
-> Compiler (Page a) (Page a) | Resulting compiler |
Render tags with links
:: (Page a -> [String]) | Function to get the tags |
-> String | Destination key |
-> (String -> Identifier a) | Create a link for a tag |
-> Compiler (Page a) (Page a) | Resulting compiler |
Render tags with links with custom function to get tags. It is typically
together with getTags
like this:
renderTagsFieldWith (customFunction . getTags) "tags" (fromCapture "tags/*")
:: String | Destination key |
-> (String -> Identifier a) | Create a category link |
-> Compiler (Page a) (Page a) | Resulting compiler |
Render the category in a link