Next: , Previous: , Up: Programming Interface   [Contents][Index]


5.2 Posts

(use-modules (haunt post))

Posts represent the articles that are kept in a site’s post directory and written in a markup format that Haunt can understand. See Readers for how files on disk can be transformed into posts.

Procedure: make-post file-name metadata sxml

Create a new post object that represents the contents of the file file-name. The body of the post, sxml, is represented as an SXML tree (see SXML in GNU Guile Reference Manual) and the metadata is an association list (see Association Lists in GNU Guile Reference Manual) of arbitrary key/value pairs.

Procedure: post? object

Return #t if object is a post.

Procedure: post-file-name post

Return the file name for post.

Procedure: post-metadata post

Return the metadata association list for post.

Procedure: post-sxml post

Return the SXML tree for post.

Procedure: post-ref post key

Return the metadata value corresponding to key within post.

Procedure: post-slug post

Return a URL slug suitable for the file name of post. If a custom slug metadata value exists for post then that is returned. Otherwise, a slug is automatically generated from the title metadata value.

The original post-slug procedure above has some less than ideal behavior. One issue is that version numbers like “1.2.3” get transformed to “123” rather than something more sensible like “1-2-3”. Unfortunately, changing this behavior would mean breaking the URLs for existing Haunt sites. Instead, users may opt-in to using post-slug-v2 by passing it as the #:make-slug argument to make-site. See Sites for more information.

Procedure: post-slug-v2 post

Transform the title of post into a URL slug. This second revision does a better job than the original. Like post-slug, if a custom slug metadata value exists for post then that is returned. Otherwise, a slug is automatically generated from the title metadata value.

Variable: %default-date

The default date of a post when no other date is specified in the metadata association list.

Procedure: post-date post

Return the date for post, or %default-date if no date is specified.

Procedure: posts/reverse-chronological posts

Sort posts, a list of posts, in reverse chronological order.

Procedure: post-author post

Return the author of post, or #f if no author is specified.

Procedure: post-tags post

Return list of tags for post, or the empty list if no tags are specified.

Procedure: post-title post

Return the title of post, or #f if no title is specified.

Procedure: posts/group-by-tag posts

Create an association list of tags mapped to the posts in the list posts that used them.


Next: Readers, Previous: Sites, Up: Programming Interface   [Contents][Index]