@anydigital/11ty-bricks 1.0.0-alpha → 1.0.0-alpha.11
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 +613 -16
- package/package.json +8 -1
- package/src/bricks.js +125 -0
- package/src/byAttrFilter.js +35 -0
- package/src/byAttrFilter.test.js +105 -0
- package/src/cli/download-files.js +136 -0
- package/src/fragments.js +34 -0
- package/src/index.cjs +14 -5
- package/src/index.js +18 -9
- package/src/markdown.js +58 -0
- package/src/{autoRaw.test.js → markdown.test.js} +66 -1
- package/src/setAttrFilter.js +17 -0
- package/src/siteData.js +12 -0
- package/src/starter/admin/index.html +13 -0
- package/src/starter/eleventy.config.js +67 -0
- package/src/starter/tailwind.config.js +7 -0
- package/src/autoRaw.js +0 -28
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/* CLI */
|
|
2
|
+
import minimist from "minimist";
|
|
3
|
+
/* Plugins */
|
|
4
|
+
import { RenderPlugin } from "@11ty/eleventy";
|
|
5
|
+
import eleventyNavigationPlugin from "@11ty/eleventy-navigation";
|
|
6
|
+
import eleventyBricksPlugin from "@anydigital/11ty-bricks";
|
|
7
|
+
/* Libraries */
|
|
8
|
+
import markdownIt from "markdown-it";
|
|
9
|
+
import markdownItAnchor from "markdown-it-anchor";
|
|
10
|
+
/* Data */
|
|
11
|
+
import yaml from "js-yaml";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Eleventy Configuration
|
|
15
|
+
* @param {Object} eleventyConfig - The Eleventy configuration object
|
|
16
|
+
* @returns {Object} The Eleventy configuration object
|
|
17
|
+
*/
|
|
18
|
+
export default function(eleventyConfig) {
|
|
19
|
+
/* CLI support */
|
|
20
|
+
const argv = minimist(process.argv.slice(2));
|
|
21
|
+
const inputDir = argv.input || "src";
|
|
22
|
+
|
|
23
|
+
/* Plugins */
|
|
24
|
+
eleventyConfig.addPlugin(RenderPlugin);
|
|
25
|
+
eleventyConfig.addPlugin(eleventyNavigationPlugin);
|
|
26
|
+
eleventyConfig.addPlugin(eleventyBricksPlugin, {
|
|
27
|
+
bricks: true,
|
|
28
|
+
fragments: true,
|
|
29
|
+
mdAutoNl2br: true,
|
|
30
|
+
mdAutoRawTags: true,
|
|
31
|
+
setAttrFilter: true,
|
|
32
|
+
byAttrFilter: true,
|
|
33
|
+
siteData: true
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
/* Libraries */
|
|
37
|
+
eleventyConfig.setLibrary("md", markdownIt({
|
|
38
|
+
html: true,
|
|
39
|
+
breaks: true,
|
|
40
|
+
linkify: true
|
|
41
|
+
}).use(markdownItAnchor, {
|
|
42
|
+
permalink: markdownItAnchor.permalink.headerLink()
|
|
43
|
+
}));
|
|
44
|
+
|
|
45
|
+
/* Data */
|
|
46
|
+
eleventyConfig.addDataExtension("yml", (contents) => yaml.safeLoad(contents));
|
|
47
|
+
|
|
48
|
+
/* Build */
|
|
49
|
+
eleventyConfig.addPassthroughCopy({
|
|
50
|
+
"_public": ".",
|
|
51
|
+
...(inputDir !== "src" && { [`${inputDir}/_public`]: "." })
|
|
52
|
+
}, { expand: true }); // This follows/resolves symbolic links
|
|
53
|
+
|
|
54
|
+
/* Dev tools */
|
|
55
|
+
// Follow symlinks in Chokidar used by 11ty to watch files
|
|
56
|
+
eleventyConfig.setChokidarConfig({ followSymlinks: true });
|
|
57
|
+
|
|
58
|
+
/* Config */
|
|
59
|
+
return {
|
|
60
|
+
templateFormats: ["md", "njk"],
|
|
61
|
+
htmlTemplateEngine: "njk",
|
|
62
|
+
dir: {
|
|
63
|
+
input: inputDir,
|
|
64
|
+
includes: "_template"
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
};
|
package/src/autoRaw.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Transform Nunjucks syntax in content by wrapping it with raw tags
|
|
3
|
-
*
|
|
4
|
-
* This function wraps Nunjucks syntax ({{, }}, {%, %}) with {% raw %} tags
|
|
5
|
-
* to prevent them from being processed by the template engine.
|
|
6
|
-
*
|
|
7
|
-
* @param {string} content - The content to transform
|
|
8
|
-
* @returns {string} The transformed content with Nunjucks syntax wrapped
|
|
9
|
-
*/
|
|
10
|
-
export function transformAutoRaw(content) {
|
|
11
|
-
// This regex looks for {{, }}, {%, or %} individually and wraps them
|
|
12
|
-
return content.replace(/({{|}}|{%|%})/g, "{% raw %}$1{% endraw %}");
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* autoRaw - Forbid Nunjucks processing in Markdown files
|
|
17
|
-
*
|
|
18
|
-
* This preprocessor wraps Nunjucks syntax ({{, }}, {%, %}) with {% raw %} tags
|
|
19
|
-
* to prevent them from being processed by the template engine in Markdown files.
|
|
20
|
-
*
|
|
21
|
-
* @param {Object} eleventyConfig - The Eleventy configuration object
|
|
22
|
-
*/
|
|
23
|
-
export function autoRaw(eleventyConfig) {
|
|
24
|
-
eleventyConfig.addPreprocessor("autoRaw", "md", (data, content) => {
|
|
25
|
-
return transformAutoRaw(content);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|