eleventy-plugin-asciidoc 1.3.1 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -2
- package/lib/eleventy-asciidoc.js +11 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,8 +10,8 @@ The plugin uses [Asciidoctor.js](https://docs.asciidoctor.org/asciidoctor.js) un
|
|
|
10
10
|
|
|
11
11
|
- Supports the default [YAML front matter](https://www.11ty.dev/docs/data-frontmatter/).
|
|
12
12
|
- Supports [AsciiDoc document title](https://docs.asciidoctor.org/asciidoc/latest/document/title/#title-syntax)
|
|
13
|
-
- Other attributes in the AsciiDoc files are made available through `
|
|
14
|
-
- Example `:author: Jane Doe` in the `.adoc` file will be available as `
|
|
13
|
+
- Other attributes in the AsciiDoc files are made available in templates through `asciidocAttributes`.
|
|
14
|
+
- Example `:author: Jane Doe` in the `.adoc` file will be available as `asciidocAttrbutes.author`
|
|
15
15
|
|
|
16
16
|
## Usage
|
|
17
17
|
|
|
@@ -49,3 +49,13 @@ module.exports = function (eleventyConfig) {
|
|
|
49
49
|
});
|
|
50
50
|
};
|
|
51
51
|
```
|
|
52
|
+
|
|
53
|
+
### CSS Styles
|
|
54
|
+
|
|
55
|
+
The plugin does not include any CSS styles. It is up to you to style the content.
|
|
56
|
+
|
|
57
|
+
The quick way to style the content is to use the CSS file from Asciidoctor.js. The CSS file is [available on cdnjs](https://cdnjs.com/libraries/asciidoctor.js).
|
|
58
|
+
|
|
59
|
+
## Enhancements
|
|
60
|
+
|
|
61
|
+
- [Tutorial on adding syntax highlighting](https://saneef.com/tutorials/asciidoc-syntax-highlighting/)
|
package/lib/eleventy-asciidoc.js
CHANGED
|
@@ -4,6 +4,7 @@ const asciidoctor = require("asciidoctor").default();
|
|
|
4
4
|
const debug = require("debug")("eleventy-plugin-asciidoc");
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const matter = require("gray-matter");
|
|
7
|
+
const nunjucks = require("nunjucks");
|
|
7
8
|
|
|
8
9
|
/** @typedef {import('asciidoctor').Asciidoctor.ProcessorOptions} ProcessorOptions */
|
|
9
10
|
/** @typedef {import('gray-matter').GrayMatterFile} GrayMatterFile */
|
|
@@ -30,7 +31,7 @@ const getData = (inputPath) => {
|
|
|
30
31
|
const attributes = doc.getAttributes();
|
|
31
32
|
const title = doc.getDocumentTitle();
|
|
32
33
|
debug(`Document title ${title}`);
|
|
33
|
-
debug(`Document attributes: ${attributes}`);
|
|
34
|
+
debug(`Document attributes: ${JSON.stringify(attributes)}`);
|
|
34
35
|
|
|
35
36
|
return {
|
|
36
37
|
title,
|
|
@@ -52,7 +53,15 @@ function eleventyAsciidoctor(convertOptions = {}) {
|
|
|
52
53
|
...convertOptions,
|
|
53
54
|
};
|
|
54
55
|
|
|
55
|
-
const compile = (
|
|
56
|
+
const compile = (str, inputPath) => (data) => {
|
|
57
|
+
if (str) {
|
|
58
|
+
// So if str has a value, it's a permalink (which can be a string or a function)
|
|
59
|
+
debug(`Permalink: ${str}`);
|
|
60
|
+
return typeof str === "function"
|
|
61
|
+
? str(data)
|
|
62
|
+
: nunjucks.renderString(str, data);
|
|
63
|
+
}
|
|
64
|
+
|
|
56
65
|
debug(`Reading ${inputPath}`);
|
|
57
66
|
const { content } = readFileSync(inputPath);
|
|
58
67
|
|