eleventy-plugin-asciidoc 4.0.1 → 4.0.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.
@@ -77,15 +77,7 @@ function eleventyAsciidoctor(convertOptions = {}) {
77
77
  ...convertOptions,
78
78
  };
79
79
 
80
- const compile = (str, inputPath) => (data) => {
81
- if (str) {
82
- // So if str has a value, it's a permalink (which can be a string or a function)
83
- debug(`Permalink: ${str}`);
84
- return typeof str === "function"
85
- ? str(data)
86
- : nunjucks.renderString(str, data);
87
- }
88
-
80
+ const compile = (_contents, inputPath) => (data) => {
89
81
  debug(`Reading ${inputPath}`);
90
82
  const { content } = readFileSync(inputPath);
91
83
 
@@ -97,8 +89,11 @@ function eleventyAsciidoctor(convertOptions = {}) {
97
89
 
98
90
  if (outdir === undefined) {
99
91
  const { page } = data ?? {};
100
- const { outputPath } = page ?? {};
101
- if (outputPath !== undefined) {
92
+
93
+ // When front matter `permalink` is `false`, `outputPath` will be `false'.
94
+ // So, keeping that as default value.
95
+ const { outputPath = false } = page ?? {};
96
+ if (outputPath !== false) {
102
97
  outdir = path.dirname(outputPath);
103
98
  }
104
99
  }
@@ -131,12 +126,28 @@ function eleventyAsciidoctor(convertOptions = {}) {
131
126
  }
132
127
  };
133
128
 
129
+ const permalink = function (contents, _inputPath) {
130
+ if (contents && typeof contents === "string") {
131
+ return async (data) => {
132
+ const permalink = nunjucks.renderString(contents, data);
133
+ debug("permalink: ", permalink);
134
+ return permalink;
135
+ };
136
+ }
137
+
138
+ // Fallbacks to Eleventy default behaviour
139
+ return contents;
140
+ };
141
+
134
142
  const getData = generateGetData(options);
135
143
 
136
144
  return {
137
145
  read: false,
138
146
  getData,
139
147
  compile,
148
+ compileOptions: {
149
+ permalink,
150
+ },
140
151
  };
141
152
  }
142
153
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eleventy-plugin-asciidoc",
3
- "version": "4.0.1",
3
+ "version": "4.0.3",
4
4
  "description": "Adds support for AsciiDoc to Eleventy",
5
5
  "main": ".eleventy.js",
6
6
  "funding": "https://github.com/sponsors/saneef/",
@@ -27,22 +27,22 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@asciidoctor/core": "^3.0.4",
30
- "debug": "^4.3.4",
30
+ "debug": "^4.4.0",
31
31
  "gray-matter": "^4.0.3",
32
32
  "nunjucks": "^3.2.4"
33
33
  },
34
34
  "devDependencies": {
35
- "@11ty/eleventy": "^2.0.1",
36
- "ava": "^6.1.1",
35
+ "@11ty/eleventy": "^3.0.0",
36
+ "ava": "^6.2.0",
37
37
  "eslint": "^8.56.0",
38
- "eslint-config-prettier": "^9.1.0",
38
+ "eslint-config-prettier": "^10.0.1",
39
39
  "eslint-config-xo-space": "^0.35.0",
40
- "eslint-plugin-prettier": "^5.1.3",
41
- "husky": "^9.0.11",
42
- "lint-staged": "^15.2.2",
43
- "nyc": "^15.1.0",
44
- "prettier": "^3.2.5",
45
- "rimraf": "^5.0.5"
40
+ "eslint-plugin-prettier": "^5.2.3",
41
+ "husky": "^9.1.7",
42
+ "lint-staged": "^15.4.3",
43
+ "nyc": "^17.1.0",
44
+ "prettier": "^3.5.2",
45
+ "rimraf": "^6.0.1"
46
46
  },
47
47
  "lint-staged": {
48
48
  "*.js": "eslint --cache --fix --ignore-pattern \"!.eleventy.js\"",