@anyblades/eleventy-blades 0.28.0-beta.3 → 0.29.0-alpha
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 +63 -53
- package/package.json +1 -1
- package/src/do/package.json +3 -6
- package/src/eleventy.config.js +5 -7
- package/src/filters/attr_concat.js +2 -2
- package/src/filters/attr_includes.js +1 -1
- package/src/filters/attr_set.js +1 -1
- package/src/filters/remove_tag.js +1 -1
- package/src/filters/strip_tag.js +1 -1
- package/src/processors/markdown.js +1 -1
- /package/{LICENSE → LICENSE.md} +0 -0
package/README.md
CHANGED
|
@@ -1,45 +1,57 @@
|
|
|
1
|
-
## <sub>Build Awesome /</sub><br> Eleventy blades <sup></sup>
|
|
2
|
-
|
|
3
1
|
<!--section:summary-->
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
<!--section:docs-->
|
|
8
|
-
|
|
9
|
-
## Documentation
|
|
10
|
-
|
|
11
|
-
<!--prettier-ignore-->
|
|
12
|
-
- [Filters]( https://blades.ninja/build-awesome-11ty/filters/)
|
|
13
|
-
- [attr_concat]( https://blades.ninja/build-awesome-11ty/filters/#attr-concat),
|
|
14
|
-
[attr_includes]( https://blades.ninja/build-awesome-11ty/filters/#attr-includes),
|
|
15
|
-
[attr_set]( https://blades.ninja/build-awesome-11ty/filters/#attr-set)
|
|
16
|
-
- [date]( https://blades.ninja/build-awesome-11ty/filters/#date)
|
|
17
|
-
- [fetch]( https://blades.ninja/build-awesome-11ty/filters/#fetch) <!--{data-marker=🥷}-->
|
|
18
|
-
- [if]( https://blades.ninja/build-awesome-11ty/filters/#if)
|
|
19
|
-
- [markdownify]( https://blades.ninja/build-awesome-11ty/filters/#markdownify)
|
|
20
|
-
- [merge]( https://blades.ninja/build-awesome-11ty/filters/#merge)
|
|
21
|
-
- [remove_tag]( https://blades.ninja/build-awesome-11ty/filters/#remove-tag),
|
|
22
|
-
[strip_tag]( https://blades.ninja/build-awesome-11ty/filters/#strip-tag)
|
|
23
|
-
- [section]( https://blades.ninja/build-awesome-11ty/filters/#section) <!--{data-marker=🥷}-->
|
|
24
|
-
- [unindent]( https://blades.ninja/build-awesome-11ty/filters/#unindent)
|
|
25
|
-
- [Processors]( https://blades.ninja/build-awesome-11ty/processors/)
|
|
26
|
-
- [Auto link favicons]( https://blades.ninja/build-awesome-11ty/processors/#auto-link-favicons) <!--{data-marker=🥷}-->
|
|
27
|
-
- [Auto-raw tags]( https://blades.ninja/build-awesome-11ty/processors/#md-auto-raw)
|
|
28
|
-
- [Auto newlines-to-br](https://blades.ninja/build-awesome-11ty/processors/#md-auto-br)
|
|
29
|
-
- [Hidden markdown attrs<i> 🆕</i>](https://blades.ninja/build-awesome-11ty/processors/#md-hidden-attrs) <!--{data-marker=🥷}-->
|
|
30
|
-
- [Power tools]( https://blades.ninja/build-awesome-11ty/tools/)
|
|
31
|
-
- [Base config file]( https://blades.ninja/build-awesome-11ty/tools/#base-config) <!--{data-marker=🥷}-->
|
|
32
|
-
- [Base npm scripts]( https://blades.ninja/build-awesome-11ty/tools/#base-scripts) <!--{data-marker=🥷}-->
|
|
33
|
-
- [Data helpers]( https://blades.ninja/build-awesome-11ty/tools/#data-helpers)
|
|
34
|
-
- [Blades starters]( https://blades.ninja/build-awesome-11ty/tools/#starters) <!--{data-marker=🥷}-->
|
|
3
|
+
# Eleventy 🥷 *Bl*ades
|
|
35
4
|
|
|
36
|
-
|
|
5
|
+
<big>Ultimate blade kit for 11ty (Build Awesome).</big>
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
[](https://github.com/anyblades/eleventy-blades)
|
|
9
|
+
[](https://github.com/anyblades/eleventy-blades)
|
|
10
|
+
|
|
11
|
+
<!--section:gh-only-->
|
|
12
|
+
|
|
13
|
+
## [Documentation ↗](https://blades.ninja/build-awesome-11ty/)
|
|
14
|
+
|
|
15
|
+
### [Filters](https://blades.ninja/build-awesome-11ty/filters/)
|
|
16
|
+
|
|
17
|
+
<!-- ToC from https://blades.ninja/build-awesome-11ty/#filters -->
|
|
18
|
+
<ul class="columns"><li><a href="https://blades.ninja/build-awesome-11ty/filters/#attr-concat" tabindex="-1">attr_concat</a></li><p></p>
|
|
19
|
+
<li><a href="https://blades.ninja/build-awesome-11ty/filters/#attr-includes" tabindex="-1">attr_includes</a></li>
|
|
20
|
+
<li><a href="https://blades.ninja/build-awesome-11ty/filters/#attr-set" tabindex="-1">attr_set</a></li>
|
|
21
|
+
<li><a href="https://blades.ninja/build-awesome-11ty/filters/#date" tabindex="-1">date</a></li>
|
|
22
|
+
<li><a href="https://blades.ninja/build-awesome-11ty/filters/#fetch" tabindex="-1">fetch</a></li>
|
|
23
|
+
<li><a href="https://blades.ninja/build-awesome-11ty/filters/#if" tabindex="-1">if</a></li>
|
|
24
|
+
<li><a href="https://blades.ninja/build-awesome-11ty/filters/#markdownify" tabindex="-1">markdownify</a></li>
|
|
25
|
+
<li><a href="https://blades.ninja/build-awesome-11ty/filters/#merge" tabindex="-1">merge</a></li>
|
|
26
|
+
<li><a href="https://blades.ninja/build-awesome-11ty/filters/#remove-tag" tabindex="-1">remove_tag</a></li>
|
|
27
|
+
<li><a href="https://blades.ninja/build-awesome-11ty/filters/#section" tabindex="-1">section</a></li>
|
|
28
|
+
<li><a href="https://blades.ninja/build-awesome-11ty/filters/#strip-tag" tabindex="-1">strip_tag</a></li>
|
|
29
|
+
<li><a href="https://blades.ninja/build-awesome-11ty/filters/#unindent" tabindex="-1">unindent</a></li>
|
|
30
|
+
<li><a href="https://blades.ninja/build-awesome-11ty/filters/#install" tabindex="-1">Install</a></li></ul>
|
|
31
|
+
|
|
32
|
+
### [Processors](https://blades.ninja/build-awesome-11ty/processors/)
|
|
33
|
+
|
|
34
|
+
<!-- ToC from https://blades.ninja/build-awesome-11ty/#processors -->
|
|
35
|
+
<ul class="columns"><li><a href="https://blades.ninja/build-awesome-11ty/processors/#auto-link-favicons" tabindex="-1">autoLinkFavicons postprocessor (transformer)</a></li><p></p>
|
|
36
|
+
<li><a href="https://blades.ninja/build-awesome-11ty/processors/#md-auto-raw" tabindex="-1">mdAutoRawTags preprocessor</a></li>
|
|
37
|
+
<li><a href="https://blades.ninja/build-awesome-11ty/processors/#md-auto-br" tabindex="-1">mdAutoNl2br converter</a></li>
|
|
38
|
+
<li><a href="https://blades.ninja/build-awesome-11ty/processors/#md-hidden-attrs" tabindex="-1">Hidden Markdown attributes using HTML comments</a></li>
|
|
39
|
+
<li><a href="https://blades.ninja/build-awesome-11ty/processors/#install" tabindex="-1">Install</a></li></ul>
|
|
40
|
+
|
|
41
|
+
### [Power tools](https://blades.ninja/build-awesome-11ty/tools/)
|
|
42
|
+
|
|
43
|
+
<!-- ToC from https://blades.ninja/build-awesome-11ty/#tools -->
|
|
44
|
+
<ul class="columns"><li><a href="https://blades.ninja/build-awesome-11ty/tools/#starters" tabindex="-1">Modern starters</a></li><p></p>
|
|
45
|
+
<li><a href="https://blades.ninja/build-awesome-11ty/tools/#base-config" tabindex="-1">Base eleventy.config.js</a></li>
|
|
46
|
+
<li><a href="https://blades.ninja/build-awesome-11ty/tools/#base-scripts" tabindex="-1">Base 11ty npm scripts via npm workspace</a></li>
|
|
47
|
+
<li><a href="https://blades.ninja/build-awesome-11ty/tools/#data-helpers" tabindex="-1">Data helpers</a></li>
|
|
48
|
+
<li><a href="https://blades.ninja/build-awesome-11ty/tools/#more" tabindex="-1">More</a><ul><li><a href="https://blades.ninja/build-awesome-11ty/tools/#find-and-kill-11ty-processes" tabindex="-1">Find and kill 11ty processes</a></li></ul></li></ul>
|
|
37
49
|
|
|
38
50
|
---
|
|
39
51
|
|
|
40
|
-
|
|
52
|
+
<!--section:install-->
|
|
41
53
|
|
|
42
|
-
|
|
54
|
+
## Install
|
|
43
55
|
|
|
44
56
|
```sh
|
|
45
57
|
npm install @anyblades/eleventy-blades
|
|
@@ -47,7 +59,7 @@ npm install @anyblades/eleventy-blades
|
|
|
47
59
|
|
|
48
60
|
Then choose one of the following options:
|
|
49
61
|
|
|
50
|
-
<mark>A. All-in</mark> managed by Eleventy Blades:
|
|
62
|
+
###### <mark>A. All-in</mark> managed by Eleventy Blades:
|
|
51
63
|
|
|
52
64
|
Consider symlinking entire `eleventy.config.js` as a set-and-forget zero-config zero-maintenance solution:
|
|
53
65
|
|
|
@@ -62,7 +74,7 @@ Living examples:
|
|
|
62
74
|
- https://github.com/anyblades/build-awesome-starter
|
|
63
75
|
- https://github.com/anyblades/bladeswitch
|
|
64
76
|
|
|
65
|
-
<mark>B. Base config</mark> by Eleventy Blades with
|
|
77
|
+
###### <mark>B. Base config</mark> by Eleventy Blades with overrides in `eleventy.config.js`:
|
|
66
78
|
|
|
67
79
|
```js
|
|
68
80
|
import baseConfig from "@anyblades/eleventy-blades/base-config";
|
|
@@ -75,9 +87,9 @@ export default function (eleventyConfig) {
|
|
|
75
87
|
}
|
|
76
88
|
```
|
|
77
89
|
|
|
78
|
-
Living example: https://github.com/
|
|
90
|
+
Living example: https://github.com/johnheenan/minform/blob/main/eleventy.config.js
|
|
79
91
|
|
|
80
|
-
<mark>C. Plug-in</mark> Eleventy Blades in
|
|
92
|
+
###### <mark>C. Plug-in</mark> Eleventy Blades in existing `eleventy.config.js`:
|
|
81
93
|
|
|
82
94
|
```js
|
|
83
95
|
import eleventyBladesPlugin from "@anyblades/eleventy-blades";
|
|
@@ -93,7 +105,7 @@ export default function (eleventyConfig) {
|
|
|
93
105
|
}
|
|
94
106
|
```
|
|
95
107
|
|
|
96
|
-
<mark>D. Individual imports</mark> from Eleventy Blades in
|
|
108
|
+
###### <mark>D. Individual imports</mark> from Eleventy Blades in `eleventy.config.js`:
|
|
97
109
|
|
|
98
110
|
```js
|
|
99
111
|
import { siteData, mdAutoRawTags, mdAutoNl2br, autoLinkFavicons, attrSetFilter, attrConcatFilter, ... } from "@anyblades/eleventy-blades";
|
|
@@ -109,25 +121,23 @@ export default function (eleventyConfig) {
|
|
|
109
121
|
}
|
|
110
122
|
```
|
|
111
123
|
|
|
112
|
-
<
|
|
113
|
-
|
|
114
|
-
Or use a <mark>fully preconfigured template</mark> as an alternative option:
|
|
115
|
-
|
|
116
|
-
<nav>
|
|
117
|
-
|
|
118
|
-
[🥷 Build Awesome Starter ↗ <small style="white-space: nowrap">11ty + Tailwind + Typography + Blades</small>](https://github.com/anyblades/build-awesome-starter)<!--{role=button .outline}-->
|
|
119
|
-
|
|
120
|
-
[🥷 Bladeswitch Starter ↗ <small style="white-space: nowrap">11ty + Pico + Blades</small>](https://github.com/anyblades/bladeswitch)<!--{role=button .outline}-->
|
|
124
|
+
###### <mark>E. Included with</mark>
|
|
121
125
|
|
|
122
|
-
|
|
126
|
+
- https://github.com/anyblades/build-awesome-starter
|
|
127
|
+
- https://github.com/anyblades/bladeswitch starter
|
|
128
|
+
- https://github.com/johnheenan/minform starter
|
|
129
|
+
- https://github.com/hostfurl/minformhf starter
|
|
123
130
|
|
|
124
|
-
<!--section:
|
|
131
|
+
<!--section:featured-->
|
|
125
132
|
|
|
126
133
|
---
|
|
127
134
|
|
|
128
|
-
Featured by
|
|
135
|
+
## <sup>Featured by</sup><!--A-Z-->
|
|
129
136
|
|
|
130
137
|
- https://11tybundle.dev/blog/11ty-bundle-83/
|
|
138
|
+
- https://11tybundle.dev/blog/11ty-bundle-88/
|
|
131
139
|
- https://11tybundle.dev/categories/getting-started/
|
|
132
|
-
- https://hamatti.org/posts/markdown-content-split-to-sections-in-eleventy-and-nunjucks/#:~:text=anydigital
|
|
133
140
|
- https://github.com/anydigital/awesome-11ty-build-awesome
|
|
141
|
+
- https://hamatti.org/posts/markdown-content-split-to-sections-in-eleventy-and-nunjucks/#:~:text=anydigital
|
|
142
|
+
|
|
143
|
+
<!--{.unlist .columns}-->
|
package/package.json
CHANGED
package/src/do/package.json
CHANGED
|
@@ -2,14 +2,11 @@
|
|
|
2
2
|
"name": "@anyblades/eleventy-blades-do",
|
|
3
3
|
"private": true,
|
|
4
4
|
"scripts": {
|
|
5
|
-
"
|
|
6
|
-
"start": "npm run 11ty -- $ELTY_OPTIONS --serve --incremental & npm run tw -- --watch",
|
|
7
|
-
"prerestart": "npm run 11ty:clean",
|
|
5
|
+
"start": "npm run 11ty -- $ELTY_OPTIONS --serve --incremental & npm run tw -- $TW_OPTIONS --watch",
|
|
8
6
|
"stage": "npm run 11ty:clean; npm run build && serve ../_site",
|
|
7
|
+
"build": "npm run tw -- $TW_OPTIONS && npm run 11ty -- $ELTY_OPTIONS",
|
|
9
8
|
"11ty": "cd ../ && NODE_OPTIONS='--preserve-symlinks' eleventy",
|
|
10
9
|
"11ty:clean": "rm -r ../_site",
|
|
11
|
-
"
|
|
12
|
-
"tw": "cd ../ && tailwindcss -i ./_styles/styles.css -o ./_public/styles.css",
|
|
13
|
-
"tw:debug": "DEBUG=* npm run tw --"
|
|
10
|
+
"tw": "cd ../ && tailwindcss"
|
|
14
11
|
}
|
|
15
12
|
}
|
package/src/eleventy.config.js
CHANGED
|
@@ -63,7 +63,8 @@ export default function (eleventyConfig) {
|
|
|
63
63
|
eleventyConfig.setLiquidOptions({
|
|
64
64
|
dynamicPartials: false, // allows unquoted Jekyll-style includes
|
|
65
65
|
root: [
|
|
66
|
-
|
|
66
|
+
eleventyConfig.directories.includes,
|
|
67
|
+
inputDir + "../_includes", // for shared multisite includes
|
|
67
68
|
fs.realpathSync(path.resolve("./node_modules/@anyblades/blades/_includes")), // for symlinks to work after https://github.com/harttle/liquidjs/pull/870
|
|
68
69
|
],
|
|
69
70
|
});
|
|
@@ -94,9 +95,9 @@ export default function (eleventyConfig) {
|
|
|
94
95
|
});
|
|
95
96
|
if (pluginTOC) {
|
|
96
97
|
eleventyConfig.addPlugin(pluginTOC, {
|
|
97
|
-
ignoredElements: ["
|
|
98
|
+
ignoredElements: [".header-anchor", "sub"],
|
|
98
99
|
ul: true,
|
|
99
|
-
wrapper: (toc) =>
|
|
100
|
+
wrapper: (toc) => `${toc}`,
|
|
100
101
|
});
|
|
101
102
|
}
|
|
102
103
|
// https://www.11ty.dev/docs/plugins/rss/#virtual-template
|
|
@@ -127,10 +128,7 @@ export default function (eleventyConfig) {
|
|
|
127
128
|
if (markdownItAnchor) {
|
|
128
129
|
md = md.use(markdownItAnchor, {
|
|
129
130
|
slugify: slugify, // @TODO: TRICKS
|
|
130
|
-
permalink: markdownItAnchor.permalink.ariaHidden(
|
|
131
|
-
class: null,
|
|
132
|
-
renderAttrs: () => ({ "data-is-anchor": true }),
|
|
133
|
-
}),
|
|
131
|
+
permalink: markdownItAnchor.permalink.ariaHidden(),
|
|
134
132
|
});
|
|
135
133
|
}
|
|
136
134
|
if (markdownItAttrs) md = md.use(markdownItAttrs);
|
|
@@ -80,13 +80,13 @@ A filter that concatenates values to an attribute array, returning a new object
|
|
|
80
80
|
- Logs an error if the existing attribute is not an array
|
|
81
81
|
- `TBC:` Supports nested attributes (e.g., `data.tags`)
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
##### Example: Add tags to a post object in `.njk`:
|
|
84
84
|
|
|
85
85
|
```jinja2
|
|
86
86
|
{% set enhancedPost = post | attr_concat('tags', ['featured', 'popular']) %}
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
##### `PRO` Example: Add scripts and styles to the `site` object in `.liquid`:
|
|
90
90
|
|
|
91
91
|
```liquid
|
|
92
92
|
{% capture _ %}[
|
|
@@ -53,7 +53,7 @@ A filter that filters a list of items by checking if an attribute array includes
|
|
|
53
53
|
|
|
54
54
|
**Why use this?** When working with Eleventy collections, you often need to filter items based on tags or other array attributes in front matter. The `attr_includes` filter provides a flexible way to filter by any array attribute, with support for nested properties using dot notation.
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
##### Example: Get all posts that include `#javascript` tag
|
|
57
57
|
|
|
58
58
|
```jinja2 {data-caption="in .njk:"}
|
|
59
59
|
{% set js_posts = collections.all | attr_includes('data.tags', '#javascript') %}
|
package/src/filters/attr_set.js
CHANGED
|
@@ -33,7 +33,7 @@ export function attrSetFilter(eleventyConfig) {
|
|
|
33
33
|
|
|
34
34
|
A filter that creates a new object with an overridden attribute value. This is useful for modifying data objects in templates without mutating the original. Or even constructing an object from scratch.
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
##### Example: How to pass object(s) as argument(s) to a filter in `.liquid`?
|
|
37
37
|
|
|
38
38
|
```liquid {data-caption="trick for '| renderContent' filter"}
|
|
39
39
|
{% assign _ctx = null | attr_set: 'collections', collections %}
|
|
@@ -60,7 +60,7 @@ A filter that removes a specified HTML element from provided HTML content. It re
|
|
|
60
60
|
|
|
61
61
|
**Security note:** While this filter can help sanitize HTML content, it should not be relied upon as the sole security measure. For critical security requirements, use a dedicated HTML sanitization library on the server side before content reaches your templates.
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
##### Example: Remove all script tags from content <!-- @TODO: better examples -->
|
|
64
64
|
|
|
65
65
|
```jinja2
|
|
66
66
|
{% set cleanContent = htmlContent | remove_tag('script') %}
|
package/src/filters/strip_tag.js
CHANGED
|
@@ -57,7 +57,7 @@ A filter that strips a specified HTML element from content while keeping its inn
|
|
|
57
57
|
- Case-insensitive matching
|
|
58
58
|
- Non-destructive: Returns a new string, leaves the original unchanged
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
##### Example: Unwrap a wrapping `<div>` from content
|
|
61
61
|
|
|
62
62
|
```jinja2
|
|
63
63
|
{% set unwrapped = htmlContent | strip_tag('div') %}
|
|
@@ -47,7 +47,7 @@ export function transformNl2br(content) {
|
|
|
47
47
|
}
|
|
48
48
|
/*```
|
|
49
49
|
|
|
50
|
-
### Hidden Markdown attributes using HTML comments
|
|
50
|
+
### Hidden Markdown attributes using HTML comments <sub>`<!--{...}-—>` trick via `mdAutoUncommentAttrs` converter</sub> {#md-hidden-attrs}
|
|
51
51
|
|
|
52
52
|
This function amends the markdown library to automatically expand
|
|
53
53
|
HTML-comment-wrapped attribute blocks `<!—-{...}-->` to their raw form
|
/package/{LICENSE → LICENSE.md}
RENAMED
|
File without changes
|