Skip to content

Commit 12b752e

Browse files
committed
docs(readme): adds note on front matter
[skip ci]
1 parent 7745f06 commit 12b752e

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,40 @@ module.exports = function (eleventyConfig) {
3535
};
3636
```
3737

38+
### Front Matter
39+
40+
You can use either [Eleventy style front matter](https://www.11ty.dev/docs/data-frontmatter/#front-matter-formats) or AsciiDoc document attributes to write front matter.
41+
42+
Any AsciiDoc document attributes that are prefixed with `eleventy-` ([configurable](#eleventyAttributesPrefix)) can be used as front matter.
43+
44+
> [!NOTE]
45+
> Only document-scoped attributes or variables can be used for front matter. Attributes that are written after the document title (`= Document Title`) will not be considered for front matter.
46+
47+
```adoc
48+
:eleventy-permalink: /hello-world/
49+
:eleventy-layout: base.njk
50+
51+
= Hello World
52+
53+
Hello everyone!
54+
```
55+
56+
The above AsciiDoc attribute front matter is the same as YAML based front matter below:
57+
58+
```adoc
59+
---
60+
permalink: /hello-world/
61+
layout: base.njk
62+
---
63+
64+
= Hello World
65+
66+
Hello everyone!
67+
```
68+
69+
> [!WARNING]
70+
> Asciidoctor.js converts all attribute names to lower case letters. Example `:eleventy-aTitle:` will be made available as `atitle` in front matter data (also as `eleventy-atitle` in document attributes).
71+
3872
### Customize with Options
3973

4074
You can pass options to `convert()` of Asciidoctor.js as second argument in `addPlugin()`.
@@ -92,6 +126,12 @@ module.exports = function (eleventyConfig) {
92126

93127
Refer to [Asciidoctor.js documentation](https://docs.asciidoctor.org/asciidoctor.js/latest/extend/extensions/) to know more about extensions.
94128

129+
#### `eleventyAttributesPrefix`
130+
131+
Default value is `eleventy-`.
132+
133+
This config can be used to change the prefix string for [AsciiDoc style front matter](#front-matter).
134+
95135
### CSS Styles
96136

97137
The plugin does not include any CSS styles. It is up to you to style the content.

0 commit comments

Comments
 (0)