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

A tableau extension.

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

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

There are currently the following extension types:

  • :pre_build - executed before tableau builds your site and writes anything to disk.
  • :pre_write - executed after tableau builds your site but before it writes anything to disk.
  • :post_write - executed after tableau builds your site and writes everything to disk.

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

Summary

Callbacks

The extension entry point.

Types

@type token() :: map()

Callbacks

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

The extension entry point.

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