View Source Tableau.Extension behaviour (tableau v0.6.0)

A tableau extension.

An extension can be used to generate other kinds of content.

options

Options

  • :key - The key in which the extensions configuration and data is loaded.
  • :type - The type of extension. See below for a description.
  • :priority - An integer used for ordering extensions of the same type.
  • :enabled - Whether or not to enable the extension. Defaults to true, and can be configured differently based on the extension.

types

Types

There are currently the following extension types:

  • :pre_build - executed before tableau builds your site and writes anything to disk.
  • :post_write - executed after tableau builds your site and writes everthing to disk.

example

Example

defmodule MySite.PostsExtension do
  use Tableau.Extension, key: :posts, type: :pre_build, priority: 300

  def run(token) do
    posts = Path.wildcard("_posts/**/*.md")

    for post <- post do
      post
      |> Markdown.render()
      |> then(&File.write(Path.join(Path.rootname(post), "index.html"), &1))
    end

    {:ok, token}
  end
end

Link to this section Summary

Callbacks

The extension entry point.

Link to this section Callbacks

@callback run(map()) :: {:ok, map()} | :error

The extension entry point.

The function is passed a token and can return a new token with new data loaded into it.