You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: lib/tableau/extensions/post_extension.ex
+27-110
Original file line number
Diff line number
Diff line change
@@ -1,101 +1,3 @@
1
-
defmoduleTableau.PostExtension.Configdo
2
-
@moduledoc"""
3
-
Configuration for PostExtension.
4
-
5
-
## Options
6
-
7
-
- `:enabled` - boolean - Extension is active or not.
8
-
- `:dir` - string - Directory to scan for markdown files. Defaults to `_posts`
9
-
- `:future` - boolean - Show posts that have dates later than the current timestamp, or time at which the site is generated.
10
-
- `:permalink` - string - Default output path for posts. Accepts `:title` as a replacement keyword, replaced with the post's provided title. If a post has a `:permalink` provided, that will override this value _for that post_.
11
-
- `:layout` - string - Elixir module providing page layout for posts. Default is nil
Markdown files (with YAML frontmatter) in the configured posts directory will be automatically compiled into Tableau pages.
@@ -104,35 +6,50 @@ defmodule Tableau.PostExtension do
104
6
105
7
## Options
106
8
107
-
Frontmatter is compiled with `yaml_elixir` and supports atom keys by prefixing a key with a colon `:title:`. Keys are all converted to atoms.
9
+
Frontmatter is compiled with `yaml_elixir` and all keys are converted to atoms.
108
10
109
-
* `:id` - An Elixir module to be used when compiling the backing `Tableau.Page`
11
+
* `:id` - An Elixir module to be used when compiling the backing `Tableau.Page`. A leaking implementation detail that should be fixed eventually.
110
12
* `:title` - The title of the post
111
13
* `:permalink` - The permalink of the post. `:title` will be replaced with the posts title and non alphanumeric characters removed. Optional.
112
-
* `:date` - An Elixir `NaiveDateTime`, often presented as a `sigil_N`
113
-
* `:layout` - A Tableau layout module.
14
+
* `:date` - A string representation of an Elixir `NaiveDateTime`, often presented as a `sigil_N`. This will be converted to your configured timezone.
15
+
* `:layout` - A string representation of a Tableau layout module.
114
16
115
17
## Example
116
18
117
-
```markdown
118
-
---
19
+
```yaml
119
20
id: "Update.Volume3"
120
21
title: "The elixir-tools Update Vol. 3"
121
22
permalink: "/news/:title"
122
23
date: "~N[2023-09-19 01:00:00]"
123
24
layout: "ElixirTools.PostLayout"
124
-
---
125
25
```
126
26
127
-
## URL generation
27
+
## Permalink
128
28
129
-
If a `:permalink` is specified in the front matter, whatever is there _will_ be the post's permalink.
29
+
The permalink is a string with colon prefixed template variables.
130
30
131
-
If a global `:permalink` is set, it's rules will be used. See `Tableau.PostExtension.Config` for details.
31
+
These variables will be swapped with the corresponding YAML Frontmatter key, with the result being piped through `to_string/1`.
132
32
133
-
If permalink is set in either location, the file's name and path will be used
33
+
In addition, there are `:year`, `:month`, and `:day` template variables.
134
34
135
-
In all cases, permalinks are stripped of non-alphanumeric characters.
35
+
## Configuration
36
+
37
+
- `:enabled` - boolean - Extension is active or not.
38
+
- `:dir` - string - Directory to scan for markdown files. Defaults to `_posts`
39
+
- `:future` - boolean - Show posts that have dates later than the current timestamp, or time at which the site is generated.
40
+
- `:permalink` - string - Default output path for posts. Accepts `:title` as a replacement keyword, replaced with the post's provided title. If a post has a `:permalink` provided, that will override this value _for that post_.
41
+
- `:layout` - string - Elixir module providing page layout for posts. Default is nil
0 commit comments