Pipeline
Idea
Pipeline is the basis of Static. All the content of the site passes through the pipeline, and is converted at the output to HTML
, XML
, and other formats. The pipeline principle is used here – each part of the pipeline processes or creates new content elements, and those, in turn, are processed by subsequent pipeline blocks.
In the static site config, the pipeline is assembled using function calls. But these functions do not create any content at the time of loading the configuration file. They only return a description of the pipeline.
For example, the pipeline of the simplest site will consist of only one element: load-content. He is responsible for reading pages and posts from files.
If we want to do something with posts and pages, for example, create for them sitemap.xml
, then we can add a call to another sitemap
function after the load-content
function. Both of these functions return the "nodes" of the pipeline. Each node is an object that will then be used when calling generic-function staticl/pipeline:process-items
to process the content.
Building Blocks
All symbols, listed below, are available in the STATICL-USER
package and can be used in the .staticlrc
file without a package prefix.
Main Building Blocks
Reads content from the disk.
By default only post
and page
files are loaded. But this list could be extended if you'll define
a custom site class and a method for staticl/content:supported-content-types
generic-function.
Filters input content objects and processes them using pipeline items given as a body.
Arguments:
PATH
: result will contain only items read from the given path.TAGS
: result will contain only items having all given tags.INVERT
: inverts effect of the filter.PIPELINE
: any number of function calls returning pipeline nodes.
Note: Right now, all new items generated by PIPELINE
given to the filter
macro
are added to the toplevel list and stay invisible to the sebsequent pipeline nodes.
The same applicable to content deletion.
Content Organization
Creates a links between pages.
Links are added to the content item's metadata and available in templates as
content.prev.url
and content.next.url
variables.
Creates additional HTML
files with post's excerpts grouped by PAGE-SIZE
items.
By default index.html
, page-2.html
, page-3.html
, etc. filenames are used, but this
can be overriden by PAGE-FILENAME-FN
argument.
The same way page title may be overriden by providing a function as PAGE-TITLE-FN
argument.
Arguments:
PAGE-FILENAME-FN
:
A callback to change page titles.
Accepts single argument - a page number and should return a pathname relative to the site's root.
By default, it returns index.html
for the first page and page-2.html
, page-3.html
for others.
If site has "clean urls" setting enabled, then additional transformation to the pathname will be applied automatically.
PAGE-TITLE-FN
:
A callback to change page titles.
Accepts single argument - a page number and should return a string.
For example, here is how you can translate page title into a russian:
(paginated-index :target-path #P"ru/"
:page-title-fn (lambda (num)
(fmt "Страница ~A" num)))
Creates additional HTML
files with post's excerpts grouped by tag names.
By default some.html
, another.html
filenames are used, but this
can be overriden by PAGE-FILENAME-FN
argument.
The same way page title may be overriden by providing a function as PAGE-TITLE-FN
argument.
Arguments:
PAGE-FILENAME-FN
:
A callback to change page titles.
Accepts single argument - a tag name and should return a pathname
By default, for tag "foo-bar" it returns foo-bar.html.
If site has "clean urls" setting enabled, then additional transformation to the pathname will be applied automatically.
PAGE-TITLE-FN
:
A callback to change page titles.
Accepts single argument - a tag name and should return a string.
For example, here is how you can translate page title into a russian:
(tags-index :target-path #P"ru/"
:page-title-fn (lambda (tag-name)
(fmt "Записи с тегом ~A" tag-name)))
Feeds
Creates an XML
feed in Atom format at TARGET-PATH
.
Only a LIMIT
latest posts are included into the feed.
Creates an XML
feed in Rss format at TARGET-PATH
.
Only a LIMIT
latest posts are included into the feed.
Plugins
Enables Disqus on the page.
To make it work, you have to register your site at Disqus and provide a short site name to the function.
Enables MathJAX
on the page if it's content has tag equal to the TAG-NAME
or if FORCE
argument was given.