Packages
tableau
0.15.1
0.30.0
0.29.0
0.28.0
0.27.1
0.27.0
0.26.1
0.26.0
0.25.1
0.25.0
0.24.1
0.24.0
0.23.1
0.23.0
0.22.0
0.21.0
0.20.1
0.20.0
0.19.0
0.18.0
0.17.1
0.17.0
0.16.0
0.15.3
0.15.2
0.15.1
0.15.0
0.14.3
0.14.2
0.14.1
0.14.0
0.13.0
0.12.0
0.11.1
0.11.0
0.10.1
0.10.0
0.9.0
0.8.0
0.7.1
0.7.0
0.6.0
0.5.0
0.4.0
0.3.1
0.3.0
0.2.0
0.1.2
0.1.1
0.1.0
Static site generator for elixir
Current section
Files
Jump to
Current section
Files
lib/tableau/extensions/page_extension.ex
defmodule Tableau.PageExtension do
@moduledoc """
Markdown files (with YAML frontmatter) in the configured pages directory will be automatically compiled into Tableau pages.
Certain frontmatter keys are required and all keys are passed as options to the `Tableau.Page`.
## Options
Frontmatter is compiled with `yaml_elixir` and all keys are converted to atoms.
* `:title` - The title of the page
* `:permalink` - The permalink of the page.
* `:layout` - A string representation of a Tableau layout module.
## Example
```yaml
id: "GettingStarted"
title: "Getting Started"
permalink: "/docs/:title"
layout: "ElixirTools.PageLayout"
```
## Permalink
The permalink is a string with colon prefixed template variables.
These variables will be swapped with the corresponding YAML Frontmatter key, with the result being piped through `to_string/1`.
## Configuration
- `:enabled` - boolean - Extension is active or not.
- `:dir` - string - Directory to scan for markdown files. Defaults to `_pages`
- `:permalink` - string - Default output path for pages. Accepts `:title` as a replacement keyword, replaced with the page's provided title. If a page has a `:permalink` provided, that will override this value _for that page_.
- `:layout` - string - Elixir module providing page layout for pages. Default is nil.
### Example
```elixir
config :tableau, Tableau.PageExtension,
enabled: true,
dir: "_docs",
permalink: "/docs/:title",
layout: "MyApp.PageLayout"
```
"""
use Tableau.Extension, key: :pages, type: :pre_build, priority: 100
def run(token) do
token = put_in(token.pages, Tableau.PageExtension.Pages.pages())
{:ok, token}
end
end