@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.
@@ -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
+ };
@@ -0,0 +1,7 @@
1
+ /** @type {import('tailwindcss').Config} */
2
+ export default {
3
+ content: [
4
+ './src*/**/*.{njk,md}',
5
+ ],
6
+ };
7
+
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
-