Skip to content

Commit

Permalink
feat: support .asciidoc and .ad file extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
saneef committed May 7, 2024
1 parent 95d2bea commit 9bbd9c4
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 2 deletions.
7 changes: 5 additions & 2 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ module.exports = {
);
}

eleventyConfig.addTemplateFormats("adoc");
eleventyConfig.addExtension("adoc", eleventyAsciidoc(converterOptions));
eleventyConfig.addTemplateFormats(["adoc", "asciidoc", "ad"]);
eleventyConfig.addExtension(
["adoc", "asciidoc", "ad"],
eleventyAsciidoc(converterOptions),
);
},
};
39 changes: 39 additions & 0 deletions tests/file-extensions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const test = require("ava").default;
const Eleventy = require("@11ty/eleventy");

test("Render alternative Asciidoc file extensions, '.asciidoc' and '.ad'", async (t) => {
const elev = new Eleventy(
"./tests/fixtures/file-extensions/src",
"./tests/fixtures/file-extensions/_site",
{
configPath: "./tests/fixtures/file-extensions/.eleventy.js",
},
);
const json = await elev.toJSON();

t.is(json.length, 3);

const page1 = json.find((d) => d.inputPath.endsWith("index.asciidoc"));
t.is(
page1.content.trim(),
`<div class="paragraph">
<p>This text is written in AsciiDoc format.</p>
</div>`,
);

const page2 = json.find((d) => d.inputPath.endsWith("another-page.adoc"));
t.is(
page2.content.trim(),
`<div class="paragraph">
<p>This text is written in AsciiDoc format.</p>
</div>`,
);

const page3 = json.find((d) => d.inputPath.endsWith("yet-another-page.ad"));
t.is(
page3.content.trim(),
`<div class="paragraph">
<p>This text is written in AsciiDoc format.</p>
</div>`,
);
});
7 changes: 7 additions & 0 deletions tests/fixtures/file-extensions/.eleventy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* eslint camelcase: ["error", {allow: ["configure_extension_registry"]}] */

const eleventyAsciidoc = require("../../../");

module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(eleventyAsciidoc);
};
3 changes: 3 additions & 0 deletions tests/fixtures/file-extensions/src/another-page.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
= Test Document for Alternate File Extension, `.adoc`

This text is written in AsciiDoc format.
3 changes: 3 additions & 0 deletions tests/fixtures/file-extensions/src/index.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
= Test Document for Alternate File Extension, `.asciidoc`

This text is written in AsciiDoc format.
3 changes: 3 additions & 0 deletions tests/fixtures/file-extensions/src/yet-another-page.ad
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
= Test Document for Alternate File Extension, `.ad`

This text is written in AsciiDoc format.

0 comments on commit 9bbd9c4

Please sign in to comment.