@anydigital/eleventy-bricks 0.27.0 → 0.27.1
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 +214 -247
- package/package.json +1 -1
- package/src/index.js +2 -2
- package/examples/section-filter.md +0 -96
- /package/src/{transforms → processors}/autoLinkFavicons.js +0 -0
- /package/src/{transforms → processors}/autoLinkFavicons.test.js +0 -0
- /package/src/{transforms → processors}/markdown.js +0 -0
- /package/src/{transforms → processors}/markdown.test.js +0 -0
package/README.md
CHANGED
|
@@ -177,13 +177,13 @@ eleventyConfig.addPlugin(eleventyBricks, {
|
|
|
177
177
|
|
|
178
178
|
The plugin also exports the following utility functions for advanced usage:
|
|
179
179
|
|
|
180
|
-
- `transformAutoRaw(content)`: The
|
|
181
|
-
- `transformNl2br(content)`: The
|
|
180
|
+
- `transformAutoRaw(content)`: The processor function used by `mdAutoRawTags` preprocessor. Can be used programmatically to wrap Nunjucks syntax with raw tags.
|
|
181
|
+
- `transformNl2br(content)`: The processor function used by `mdAutoNl2br` preprocessor. Can be used programmatically to convert `\\n` sequences to `\u003cbr\u003e` tags.
|
|
182
182
|
- `isPlainUrlText(linkText, domain)`: Helper function that checks if link text looks like a plain URL or domain.
|
|
183
183
|
- `cleanLinkText(linkText, domain)`: Helper function that cleans link text by removing protocol, domain, and leading slash.
|
|
184
184
|
- `buildFaviconLink(attrs, domain, text)`: Helper function that builds HTML for a link with favicon.
|
|
185
|
-
- `transformLink(match, attrs, url, linkText)`: The
|
|
186
|
-
- `replaceLinksInHtml(content,
|
|
185
|
+
- `transformLink(match, attrs, url, linkText)`: The processor function used by `autoLinkFavicons` that processes a single link to include a favicon.
|
|
186
|
+
- `replaceLinksInHtml(content, processor)`: Helper function that replaces all anchor links in HTML content with processed versions.
|
|
187
187
|
- `attrIncludes(collection, attrName, targetValue)`: The core logic for filtering collection items by checking if an attribute array includes a target value. Can be used programmatically to filter collections.
|
|
188
188
|
- `merge(first, ...rest)`: The core merge function used by the `merge` filter. Can be used programmatically to merge arrays or objects.
|
|
189
189
|
- `removeTag(html, tagName)`: The core function used by the `remove_tag` filter. Can be used programmatically to remove HTML tags from content.
|
|
@@ -192,37 +192,25 @@ The plugin also exports the following utility functions for advanced usage:
|
|
|
192
192
|
- `attrSet(obj, key, value)`: The core function used by the `attr_set` filter. Can be used programmatically to override object attributes.
|
|
193
193
|
- `section(content, sectionName)`: The core function used by the `section` filter. Can be used programmatically to extract named sections from content.
|
|
194
194
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
###
|
|
200
|
-
|
|
201
|
-
| Input |
|
|
202
|
-
| ---------: |
|
|
203
|
-
| {.divider} | Logical
|
|
204
|
-
|
|
|
205
|
-
|
|
|
206
|
-
|
|
|
207
|
-
| `OBJ \|` | [`
|
|
208
|
-
|
|
|
209
|
-
| `OBJ \|` | `
|
|
210
|
-
|
|
|
211
|
-
| `
|
|
212
|
-
|
|
|
213
|
-
|
|
|
214
|
-
| {.divider} | Textual |
|
|
215
|
-
| `HTML \|` | `striptags` | `strip_html` |
|
|
216
|
-
| `HTML \|` | [`remove_tag(TAG)`](#remove_tag) | [`remove_tag: TAG`](#remove_tag) |
|
|
217
|
-
| `HTML \|` | [`section(NAME)`](#section) | [`section: NAME`](#section) |
|
|
218
|
-
| `STR \|` | `remove: STR2` | `remove: STR2` |
|
|
219
|
-
| {.divider} | Other |
|
|
220
|
-
| `URL \|` | [`fetch`](#fetch) | [`fetch`](#fetch) |
|
|
221
|
-
|
|
222
|
-
Ref:
|
|
223
|
-
|
|
224
|
-
- https://mozilla.github.io/nunjucks/templating.html#builtin-filters
|
|
225
|
-
- https://shopify.github.io/liquid/
|
|
195
|
+
## Features
|
|
196
|
+
|
|
197
|
+
<!--section:filters-h3-->
|
|
198
|
+
|
|
199
|
+
### Universal 11ty filters <small>for `.njk` & `.liquid`</small> <sub>by https://github.com/anydigital/eleventy-bricks</sub>
|
|
200
|
+
|
|
201
|
+
| Input | Filter | Arguments |
|
|
202
|
+
| ---------: | --------------------------------- | -------------------------------------------------- |
|
|
203
|
+
| {.divider} | Logical filters: |
|
|
204
|
+
| `ANY \|` | [`if`](#if) | `TEST, OP, VALUE` <sub>currently only `TEST`</sub> |
|
|
205
|
+
| {.divider} | Filters for objects: |
|
|
206
|
+
| `OBJ \|` | [`merge`](#merge) | `OBJ2` |
|
|
207
|
+
| `OBJ \|` | [`attr_set`](#attr_set) | `ATTR, VALUE` |
|
|
208
|
+
| `OBJ \|` | [`attr_concat`](#attr_concat) | `ATTR, ARRAY2` |
|
|
209
|
+
| `OBJ \|` | [`attr_includes`](#attr_includes) | `ATTR, VALUE` |
|
|
210
|
+
| {.divider} | Other filters: |
|
|
211
|
+
| `URL \|` | [`fetch`](#fetch) | |
|
|
212
|
+
| `HTML \|` | [`section`](#section) | `NAME` |
|
|
213
|
+
| `HTML \|` | [`remove_tag`](#remove_tag) | `TAG` |
|
|
226
214
|
|
|
227
215
|
#### `attr_set`
|
|
228
216
|
|
|
@@ -554,15 +542,15 @@ export default function (eleventyConfig) {
|
|
|
554
542
|
```markdown
|
|
555
543
|
# My Post
|
|
556
544
|
|
|
557
|
-
|
|
545
|
+
<¡--section:intro-->
|
|
558
546
|
|
|
559
547
|
This is the introduction that appears at the top of the page.
|
|
560
548
|
|
|
561
|
-
|
|
549
|
+
<¡--section:main-->
|
|
562
550
|
|
|
563
551
|
This is the main body of the post with all the details.
|
|
564
552
|
|
|
565
|
-
|
|
553
|
+
<¡--section:summary,sidebar-->
|
|
566
554
|
|
|
567
555
|
This content appears in both the summary and the sidebar!
|
|
568
556
|
```
|
|
@@ -593,11 +581,11 @@ This content appears in both the summary and the sidebar!
|
|
|
593
581
|
|
|
594
582
|
**Features:**
|
|
595
583
|
|
|
596
|
-
- **Multiple names**: A single section can have multiple names separated by commas:
|
|
584
|
+
- **Multiple names**: A single section can have multiple names separated by commas: `<¡--section:name1,name2-->`
|
|
597
585
|
- **Case-insensitive**: Section names are matched without regard to case
|
|
598
586
|
- **Multiple occurrences**: If a section name appears multiple times, the filter concatenates all matching sections
|
|
599
587
|
- **Non-destructive**: Returns extracted content without modifying the original input
|
|
600
|
-
- **EOF support**: Sections continue until the next
|
|
588
|
+
- **EOF support**: Sections continue until the next `<¡--section*-->` marker or the end of the file
|
|
601
589
|
|
|
602
590
|
**Examples:**
|
|
603
591
|
|
|
@@ -620,8 +608,8 @@ This content appears in both the summary and the sidebar!
|
|
|
620
608
|
|
|
621
609
|
**Syntax Rules:**
|
|
622
610
|
|
|
623
|
-
- Sections start with:
|
|
624
|
-
- Sections end at the next
|
|
611
|
+
- Sections start with: `<¡--section:NAME-->` or `<¡--section:NAME1,NAME2-->`
|
|
612
|
+
- Sections end at the next `<¡--section*-->` marker or end of file
|
|
625
613
|
- Whitespace around names and inside comments is automatically trimmed
|
|
626
614
|
|
|
627
615
|
#### `if`
|
|
@@ -914,61 +902,108 @@ your-project/
|
|
|
914
902
|
|
|
915
903
|
**Note:** The filter returns raw text content. Use Eleventy's built-in filters like `| safe`, `| markdown`, or `| fromJson` to process the content as needed.
|
|
916
904
|
|
|
917
|
-
|
|
905
|
+
<!--section:data&processors-h3-->
|
|
918
906
|
|
|
919
|
-
|
|
907
|
+
### Global `site` data helpers
|
|
920
908
|
|
|
921
|
-
|
|
909
|
+
Adds global `site` data to your Eleventy project, providing commonly needed values that can be accessed in all templates:
|
|
922
910
|
|
|
923
|
-
|
|
911
|
+
| Variable | Value |
|
|
912
|
+
| ----------------- | ------------------------------------------------------------------------------------------------------------ |
|
|
913
|
+
| `{{ site.year }}` | The current year as a number (e.g., `2026`) |
|
|
914
|
+
| `{{ site.prod }}` | Boolean indicating if running in production mode (`true` for `eleventy build`, `false` for `eleventy serve`) |
|
|
924
915
|
|
|
925
|
-
|
|
916
|
+
<details>
|
|
917
|
+
<summary>Quick setup</summary>
|
|
926
918
|
|
|
927
|
-
|
|
919
|
+
```sh
|
|
920
|
+
npm install @anydigital/eleventy-bricks
|
|
921
|
+
```
|
|
928
922
|
|
|
929
|
-
|
|
923
|
+
Then choose one of the following options:
|
|
930
924
|
|
|
931
|
-
```
|
|
932
|
-
import
|
|
925
|
+
1. ```js {data-caption="As a plugin in eleventy.config.js (balanced)"}
|
|
926
|
+
import eleventyBricksPlugin from "@anydigital/eleventy-bricks";
|
|
933
927
|
|
|
934
|
-
export default function (eleventyConfig) {
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
```
|
|
928
|
+
export default function (eleventyConfig) {
|
|
929
|
+
eleventyConfig.addPlugin(eleventyBricksPlugin, { siteData: true });
|
|
930
|
+
}
|
|
931
|
+
```
|
|
932
|
+
|
|
933
|
+
2. ```js {data-caption="Individual import in eleventy.config.js (minimal)"}
|
|
934
|
+
import { siteData } from "@anydigital/eleventy-bricks";
|
|
935
|
+
|
|
936
|
+
export default function (eleventyConfig) {
|
|
937
|
+
siteData(eleventyConfig);
|
|
938
|
+
}
|
|
939
|
+
```
|
|
940
|
+
|
|
941
|
+
3. ```sh {data-caption="Symlink entire eleventy.config.js (easiest)"}
|
|
942
|
+
ln -s node_modules/@anydigital/eleventy-bricks/src/eleventy.config.js
|
|
943
|
+
```
|
|
944
|
+
|
|
945
|
+
{.list-[upper-roman]}
|
|
946
|
+
|
|
947
|
+
</details>
|
|
948
|
+
|
|
949
|
+
### `mdAutoRawTags` preprocessor
|
|
950
|
+
|
|
951
|
+
Prevents Nunjucks syntax from being processed in Markdown files by automatically wrapping `{{`, `}}`, `{%`, and `%}` with `{% raw %}` tags.
|
|
952
|
+
|
|
953
|
+
**Why use this?**
|
|
954
|
+
|
|
955
|
+
When writing documentation or tutorials about templating in Markdown files, you often want to show Nunjucks/Liquid syntax as literal text. This preprocessor automatically escapes these special characters so they display as-is instead of being processed by the template engine.
|
|
940
956
|
|
|
941
957
|
**Example:**
|
|
942
958
|
|
|
943
959
|
Before `mdAutoRawTags`, writing this in Markdown:
|
|
944
960
|
|
|
945
961
|
```markdown
|
|
946
|
-
|
|
962
|
+
### Using {{ variable }} to output variables
|
|
947
963
|
```
|
|
948
964
|
|
|
949
965
|
Would try to process `{{ variable }}` as a template variable. With `mdAutoRawTags`, it displays exactly as written.
|
|
950
966
|
|
|
951
|
-
|
|
967
|
+
<details>
|
|
968
|
+
<summary>Quick setup</summary>
|
|
952
969
|
|
|
953
|
-
|
|
970
|
+
```sh
|
|
971
|
+
npm install @anydigital/eleventy-bricks
|
|
972
|
+
```
|
|
954
973
|
|
|
955
|
-
|
|
974
|
+
Then choose one of the following options:
|
|
956
975
|
|
|
957
|
-
|
|
976
|
+
1. ```js {data-caption="As a plugin in eleventy.config.js (balanced)"}
|
|
977
|
+
import eleventyBricksPlugin from "@anydigital/eleventy-bricks";
|
|
958
978
|
|
|
959
|
-
|
|
979
|
+
export default function (eleventyConfig) {
|
|
980
|
+
eleventyConfig.addPlugin(eleventyBricksPlugin, { mdAutoRawTags: true });
|
|
981
|
+
}
|
|
982
|
+
```
|
|
960
983
|
|
|
961
|
-
|
|
984
|
+
2. ```js {data-caption="Individual import in eleventy.config.js (minimal)"}
|
|
985
|
+
import { mdAutoRawTags } from "@anydigital/eleventy-bricks";
|
|
962
986
|
|
|
963
|
-
|
|
964
|
-
|
|
987
|
+
export default function (eleventyConfig) {
|
|
988
|
+
mdAutoRawTags(eleventyConfig);
|
|
989
|
+
}
|
|
990
|
+
```
|
|
965
991
|
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
}
|
|
971
|
-
|
|
992
|
+
3. ```sh {data-caption="Symlink entire eleventy.config.js (easiest)"}
|
|
993
|
+
ln -s node_modules/@anydigital/eleventy-bricks/src/eleventy.config.js
|
|
994
|
+
```
|
|
995
|
+
|
|
996
|
+
{.list-[upper-roman]}
|
|
997
|
+
|
|
998
|
+
</details>
|
|
999
|
+
|
|
1000
|
+
### `mdAutoNl2br` converter
|
|
1001
|
+
|
|
1002
|
+
Automatically converts `\n` sequences to `<br>` tags in Markdown content. This is particularly useful for adding line breaks inside Markdown tables where standard newlines don't work.
|
|
1003
|
+
|
|
1004
|
+
**Why use this?**
|
|
1005
|
+
|
|
1006
|
+
Markdown tables don't support multi-line content in cells. By using `\n` in your content, this preprocessor will convert it to `<br>` tags, allowing you to display line breaks within table cells and other content.
|
|
972
1007
|
|
|
973
1008
|
**Example:**
|
|
974
1009
|
|
|
@@ -989,31 +1024,48 @@ Will render as:
|
|
|
989
1024
|
|
|
990
1025
|
**Note:** This processes literal `\n` sequences (backslash followed by 'n'), not actual newline characters. Type `\n` in your source files where you want line breaks.
|
|
991
1026
|
|
|
992
|
-
|
|
1027
|
+
<details>
|
|
1028
|
+
<summary>Quick setup</summary>
|
|
993
1029
|
|
|
994
|
-
|
|
1030
|
+
```sh
|
|
1031
|
+
npm install @anydigital/eleventy-bricks
|
|
1032
|
+
```
|
|
995
1033
|
|
|
996
|
-
|
|
1034
|
+
Then choose one of the following options:
|
|
997
1035
|
|
|
998
|
-
|
|
1036
|
+
1. ```js {data-caption="As a plugin in eleventy.config.js (balanced)"}
|
|
1037
|
+
import eleventyBricksPlugin from "@anydigital/eleventy-bricks";
|
|
999
1038
|
|
|
1000
|
-
|
|
1039
|
+
export default function (eleventyConfig) {
|
|
1040
|
+
eleventyConfig.addPlugin(eleventyBricksPlugin, { mdAutoNl2br: true });
|
|
1041
|
+
}
|
|
1042
|
+
```
|
|
1001
1043
|
|
|
1002
|
-
|
|
1044
|
+
2. ```js {data-caption="Individual import in eleventy.config.js (minimal)"}
|
|
1045
|
+
import { mdAutoNl2br } from "@anydigital/eleventy-bricks";
|
|
1003
1046
|
|
|
1004
|
-
|
|
1005
|
-
|
|
1047
|
+
export default function (eleventyConfig) {
|
|
1048
|
+
mdAutoNl2br(eleventyConfig);
|
|
1049
|
+
}
|
|
1050
|
+
```
|
|
1006
1051
|
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
// eleventyConfig.addPlugin(eleventyBricks, { autoLinkFavicons: true });
|
|
1011
|
-
}
|
|
1012
|
-
```
|
|
1052
|
+
3. ```sh {data-caption="Symlink entire eleventy.config.js (easiest)"}
|
|
1053
|
+
ln -s node_modules/@anydigital/eleventy-bricks/src/eleventy.config.js
|
|
1054
|
+
```
|
|
1013
1055
|
|
|
1014
|
-
|
|
1056
|
+
{.list-[upper-roman]}
|
|
1057
|
+
|
|
1058
|
+
</details>
|
|
1015
1059
|
|
|
1016
|
-
|
|
1060
|
+
### `autoLinkFavicons` processor
|
|
1061
|
+
|
|
1062
|
+
Automatically adds favicon images from Google's favicon service to links that display plain URLs or domain names. This processor processes all HTML output files and adds inline favicon images next to link text that appears to be a plain URL.
|
|
1063
|
+
|
|
1064
|
+
**Why use this?**
|
|
1065
|
+
|
|
1066
|
+
When you have links in your content that display raw URLs or domain names (like `https://example.com/page`), adding favicons provides a visual indicator of the external site. This processor automatically detects these plain-text URL links and enhances them with favicon images, making them more visually appealing and easier to recognize.
|
|
1067
|
+
|
|
1068
|
+
**How it works:**
|
|
1017
1069
|
|
|
1018
1070
|
1. Scans all HTML output files for `<a>` tags
|
|
1019
1071
|
2. Checks if the link text appears to be a plain URL or domain
|
|
@@ -1023,13 +1075,13 @@ The transform:
|
|
|
1023
1075
|
|
|
1024
1076
|
**Example:**
|
|
1025
1077
|
|
|
1026
|
-
Before
|
|
1078
|
+
Before processing:
|
|
1027
1079
|
|
|
1028
1080
|
```html
|
|
1029
1081
|
<a href="https://github.com/anydigital/eleventy-bricks">https://github.com/anydigital/eleventy-bricks</a>
|
|
1030
1082
|
```
|
|
1031
1083
|
|
|
1032
|
-
After
|
|
1084
|
+
After processing:
|
|
1033
1085
|
|
|
1034
1086
|
```html
|
|
1035
1087
|
<a href="https://github.com/anydigital/eleventy-bricks" class="whitespace-nowrap" target="_blank">
|
|
@@ -1045,124 +1097,49 @@ After transformation:
|
|
|
1045
1097
|
- Removes the trailing slash from the display text
|
|
1046
1098
|
- Only applies if at least 3 characters remain after removing the domain (to avoid showing favicons for bare domain links)
|
|
1047
1099
|
- Uses Google's favicon service at `https://www.google.com/s2/favicons?domain=DOMAIN&sz=32`
|
|
1048
|
-
- Adds `target="_blank"` to the
|
|
1100
|
+
- Adds `target="_blank"` to the processed links (only if not already present)
|
|
1049
1101
|
- Adds `whitespace-nowrap` class to the link
|
|
1050
1102
|
- Wraps the link text in a `<span>` element
|
|
1051
1103
|
- The favicon is wrapped in an `<i>` tag for easy styling
|
|
1052
1104
|
|
|
1053
|
-
|
|
1105
|
+
<details>
|
|
1106
|
+
<summary>Quick setup</summary>
|
|
1054
1107
|
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
```css
|
|
1058
|
-
/* Style the favicon wrapper */
|
|
1059
|
-
a i {
|
|
1060
|
-
display: inline-block;
|
|
1061
|
-
margin-right: 0.25em;
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
/* Style the favicon image */
|
|
1065
|
-
a i img {
|
|
1066
|
-
width: 16px;
|
|
1067
|
-
height: 16px;
|
|
1068
|
-
vertical-align: middle;
|
|
1069
|
-
}
|
|
1070
|
-
```
|
|
1071
|
-
|
|
1072
|
-
**Note:** This transform only processes HTML output files (those ending in `.html`). It does not modify the original content files.
|
|
1073
|
-
|
|
1074
|
-
### Global Data
|
|
1075
|
-
|
|
1076
|
-
Adds global site data to your Eleventy project, providing commonly needed values that can be accessed in all templates.
|
|
1077
|
-
|
|
1078
|
-
**Why use this?**
|
|
1079
|
-
|
|
1080
|
-
Many websites need access to the current year (for copyright notices) and environment information (to conditionally enable features based on production vs development). This helper provides these as global `site` data without manually setting them up.
|
|
1081
|
-
|
|
1082
|
-
**Usage:**
|
|
1083
|
-
|
|
1084
|
-
1. Enable `siteData` in your Eleventy config:
|
|
1085
|
-
|
|
1086
|
-
```javascript
|
|
1087
|
-
import { siteData } from "@anydigital/eleventy-bricks";
|
|
1088
|
-
|
|
1089
|
-
export default function (eleventyConfig) {
|
|
1090
|
-
siteData(eleventyConfig);
|
|
1091
|
-
// Or use as plugin:
|
|
1092
|
-
// eleventyConfig.addPlugin(eleventyBricks, { siteData: true });
|
|
1093
|
-
}
|
|
1094
|
-
```
|
|
1095
|
-
|
|
1096
|
-
2. Use the global data in your templates:
|
|
1097
|
-
|
|
1098
|
-
**Current Year:**
|
|
1099
|
-
|
|
1100
|
-
```njk
|
|
1101
|
-
<footer>
|
|
1102
|
-
<p>© {{ site.year }} Your Company Name. All rights reserved.</p>
|
|
1103
|
-
</footer>
|
|
1104
|
-
```
|
|
1105
|
-
|
|
1106
|
-
**Environment Check:**
|
|
1107
|
-
|
|
1108
|
-
```njk
|
|
1109
|
-
{% if site.prod %}
|
|
1110
|
-
<!-- Production-only features -->
|
|
1111
|
-
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script>
|
|
1112
|
-
{% else %}
|
|
1113
|
-
<!-- Development-only features -->
|
|
1114
|
-
<div class="dev-toolbar">Development Mode</div>
|
|
1115
|
-
{% endif %}
|
|
1108
|
+
```sh
|
|
1109
|
+
npm install @anydigital/eleventy-bricks
|
|
1116
1110
|
```
|
|
1117
1111
|
|
|
1118
|
-
|
|
1112
|
+
Then choose one of the following options:
|
|
1119
1113
|
|
|
1120
|
-
|
|
1121
|
-
|
|
1114
|
+
1. ```js {data-caption="As a plugin in eleventy.config.js (balanced)"}
|
|
1115
|
+
import eleventyBricksPlugin from "@anydigital/eleventy-bricks";
|
|
1122
1116
|
|
|
1123
|
-
|
|
1117
|
+
export default function (eleventyConfig) {
|
|
1118
|
+
eleventyConfig.addPlugin(eleventyBricksPlugin, { autoLinkFavicons: true });
|
|
1119
|
+
}
|
|
1120
|
+
```
|
|
1124
1121
|
|
|
1125
|
-
-
|
|
1126
|
-
|
|
1127
|
-
- Available globally in all templates without manual setup
|
|
1128
|
-
- No configuration required
|
|
1122
|
+
2. ```js {data-caption="Individual import in eleventy.config.js (minimal)"}
|
|
1123
|
+
import { autoLinkFavicons } from "@anydigital/eleventy-bricks";
|
|
1129
1124
|
|
|
1130
|
-
|
|
1125
|
+
export default function (eleventyConfig) {
|
|
1126
|
+
autoLinkFavicons(eleventyConfig);
|
|
1127
|
+
}
|
|
1128
|
+
```
|
|
1131
1129
|
|
|
1132
|
-
```
|
|
1133
|
-
|
|
1134
|
-
|
|
1130
|
+
3. ```sh {data-caption="Symlink entire eleventy.config.js (easiest)"}
|
|
1131
|
+
ln -s node_modules/@anydigital/eleventy-bricks/src/eleventy.config.js
|
|
1132
|
+
```
|
|
1135
1133
|
|
|
1136
|
-
{
|
|
1137
|
-
{% if site.prod %}
|
|
1138
|
-
<script src="/analytics.js"></script>
|
|
1139
|
-
{% endif %}
|
|
1134
|
+
{.list-[upper-roman]}
|
|
1140
1135
|
|
|
1141
|
-
|
|
1142
|
-
{% if site.prod %}
|
|
1143
|
-
<link rel="stylesheet" href="/css/styles.min.css">
|
|
1144
|
-
{% else %}
|
|
1145
|
-
<link rel="stylesheet" href="/css/styles.css">
|
|
1146
|
-
<script src="/live-reload.js"></script>
|
|
1147
|
-
{% endif %}
|
|
1148
|
-
```
|
|
1136
|
+
</details>
|
|
1149
1137
|
|
|
1150
|
-
|
|
1138
|
+
<!--section:config-h3-->
|
|
1151
1139
|
|
|
1152
|
-
|
|
1140
|
+
### Symlinked `eleventy.config.js` <sub>from https://github.com/anydigital/eleventy-bricks</sub>
|
|
1153
1141
|
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
- **Always up-to-date**: Configuration automatically updates when you upgrade the package
|
|
1157
|
-
- **Less maintenance**: No need to manually sync configuration changes
|
|
1158
|
-
- **Quick setup**: Get started immediately with best-practice configurations
|
|
1159
|
-
- **Easy customization**: Override specific settings by creating your own config that imports from the symlinked version
|
|
1160
|
-
|
|
1161
|
-
If you prefer to customize the configurations extensively, you can copy the files instead.
|
|
1162
|
-
|
|
1163
|
-
#### eleventy.config.js
|
|
1164
|
-
|
|
1165
|
-
A fully-configured Eleventy config file with:
|
|
1142
|
+
The package includes a fully-configured Eleventy config file `eleventy.config.js` that you can symlink to your project to get:
|
|
1166
1143
|
|
|
1167
1144
|
- All eleventy-bricks plugins enabled
|
|
1168
1145
|
- Eleventy Navigation plugin
|
|
@@ -1171,30 +1148,27 @@ A fully-configured Eleventy config file with:
|
|
|
1171
1148
|
- YAML data support
|
|
1172
1149
|
- CLI input directory support
|
|
1173
1150
|
- Symlink support for development
|
|
1151
|
+
- _and more_
|
|
1174
1152
|
|
|
1175
|
-
**
|
|
1153
|
+
**Benefits of symlinking:**
|
|
1176
1154
|
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
**Optional dependencies:**
|
|
1155
|
+
- **Always up-to-date**: Configuration automatically updates when you upgrade the package
|
|
1156
|
+
- **Less maintenance**: No need to manually sync configuration changes
|
|
1157
|
+
- **Quick setup**: Get started immediately with best-practice configurations
|
|
1158
|
+
- **Easy customization**: Override specific settings by creating your own config that imports from the symlinked version
|
|
1182
1159
|
|
|
1183
|
-
|
|
1184
|
-
# For the fetch filter
|
|
1185
|
-
npm install @11ty/eleventy-fetch
|
|
1160
|
+
**Quick setup:**
|
|
1186
1161
|
|
|
1187
|
-
|
|
1188
|
-
npm install @
|
|
1162
|
+
```sh
|
|
1163
|
+
npm install @anydigital/eleventy-bricks
|
|
1164
|
+
ln -s node_modules/@anydigital/eleventy-bricks/src/eleventy.config.js
|
|
1189
1165
|
```
|
|
1190
1166
|
|
|
1191
|
-
|
|
1167
|
+
Done! 🎉
|
|
1192
1168
|
|
|
1193
|
-
|
|
1194
|
-
ln -s node_modules/@anydigital/eleventy-bricks/src/eleventy.config.js eleventy.config.js
|
|
1195
|
-
```
|
|
1169
|
+
<!--section:cms-h4-->
|
|
1196
1170
|
|
|
1197
|
-
|
|
1171
|
+
### Symlinked CMS
|
|
1198
1172
|
|
|
1199
1173
|
A ready-to-use Sveltia CMS admin interface for content management.
|
|
1200
1174
|
|
|
@@ -1205,61 +1179,54 @@ mkdir -p admin
|
|
|
1205
1179
|
ln -s ../node_modules/@anydigital/eleventy-bricks/src/admin/index.html admin/index.html
|
|
1206
1180
|
```
|
|
1207
1181
|
|
|
1208
|
-
<!--section:npm
|
|
1182
|
+
<!--section:npm-h3-->
|
|
1209
1183
|
|
|
1210
|
-
###
|
|
1184
|
+
### Reusable 11ty npm scripts <small>via npm workspace</small> <sub>from https://github.com/anydigital/eleventy-bricks</sub>
|
|
1211
1185
|
|
|
1212
1186
|
This package provides a pre-configured `do` folder setup that helps organize your development workflow using npm workspaces. The `do` folder contains scripts for building and running your Eleventy project.
|
|
1213
1187
|
|
|
1214
|
-
**
|
|
1188
|
+
**Quick setup:**
|
|
1215
1189
|
|
|
1216
|
-
1. Create a
|
|
1190
|
+
1. Create a simple folder, which will hold reusable npm scripts:
|
|
1217
1191
|
|
|
1218
|
-
```
|
|
1219
|
-
mkdir do
|
|
1220
|
-
```
|
|
1192
|
+
```sh
|
|
1193
|
+
mkdir do
|
|
1194
|
+
```
|
|
1221
1195
|
|
|
1222
|
-
2.
|
|
1196
|
+
2. Install https://github.com/anydigital/eleventy-bricks to reuse default 11ty scripts from there:
|
|
1223
1197
|
|
|
1224
|
-
```
|
|
1225
|
-
|
|
1226
|
-
```
|
|
1198
|
+
```sh
|
|
1199
|
+
npm install @anydigital/eleventy-bricks
|
|
1200
|
+
```
|
|
1227
1201
|
|
|
1228
|
-
3.
|
|
1202
|
+
3. Symlink the `do/package.json` containing scripts into your project's `do` folder:
|
|
1229
1203
|
|
|
1230
|
-
```
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
"scripts": {
|
|
1235
|
-
"build": "npm -w do run build",
|
|
1236
|
-
"start": "npm -w do run start"
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
```
|
|
1240
|
-
|
|
1241
|
-
**Usage:**
|
|
1242
|
-
|
|
1243
|
-
Run your Eleventy project:
|
|
1204
|
+
```sh
|
|
1205
|
+
cd do
|
|
1206
|
+
ln -s node_modules/@anydigital/eleventy-bricks/src/do/package.json
|
|
1207
|
+
```
|
|
1244
1208
|
|
|
1245
|
-
|
|
1246
|
-
npm start
|
|
1247
|
-
```
|
|
1209
|
+
4. Finally register `do` folder as npm workspace in your `package.json`, and enjoy default 11ty scripts as simple as:
|
|
1248
1210
|
|
|
1249
|
-
|
|
1211
|
+
```json {data-caption="YOUR project's package.json"}
|
|
1212
|
+
{
|
|
1213
|
+
"workspaces": ["do"],
|
|
1214
|
+
"scripts": {
|
|
1215
|
+
"start": "npm -w do run start",
|
|
1216
|
+
"stage": "npm -w do run stage",
|
|
1217
|
+
"build": "npm -w do run build"
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
```
|
|
1250
1221
|
|
|
1251
|
-
|
|
1252
|
-
npm run build
|
|
1253
|
-
```
|
|
1222
|
+
**Done!** 🎉 Now you can run:
|
|
1254
1223
|
|
|
1255
|
-
|
|
1224
|
+
- `npm start` to start 11ty dev server with live reload and Tailwind watch mode
|
|
1225
|
+
- `npm run stage` to build and serve production-like site locally
|
|
1226
|
+
- `npm run build` to finally build the site for production
|
|
1227
|
+
- all available scripts: https://github.com/anydigital/eleventy-bricks/blob/main/src/do/package.json
|
|
1256
1228
|
|
|
1257
|
-
|
|
1258
|
-
- `start` - Start Eleventy dev server with live reload and Tailwind watch mode
|
|
1259
|
-
- `stage` - Clean build and serve locally for preview
|
|
1260
|
-
- `11ty` - Run Eleventy commands directly
|
|
1261
|
-
- `11ty:clean` - Remove the `_site` output directory
|
|
1262
|
-
- `tw` - Run Tailwind CSS commands
|
|
1229
|
+
**Example setup:** https://github.com/anydigital/sveleven
|
|
1263
1230
|
|
|
1264
1231
|
**Benefits:**
|
|
1265
1232
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mdAutoRawTags, mdAutoNl2br, transformAutoRaw, transformNl2br } from "./
|
|
1
|
+
import { mdAutoRawTags, mdAutoNl2br, transformAutoRaw, transformNl2br } from "./processors/markdown.js";
|
|
2
2
|
import {
|
|
3
3
|
autoLinkFavicons,
|
|
4
4
|
isPlainUrlText,
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
buildFaviconLink,
|
|
7
7
|
transformLink,
|
|
8
8
|
replaceLinksInHtml,
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./processors/autoLinkFavicons.js";
|
|
10
10
|
import { attrSetFilter, attrSet } from "./filters/attr_set.js";
|
|
11
11
|
import { attrIncludesFilter } from "./filters/attr_includes.js";
|
|
12
12
|
import { mergeFilter, merge } from "./filters/merge.js";
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# Section Filter Examples
|
|
2
|
-
|
|
3
|
-
## Basic Usage
|
|
4
|
-
|
|
5
|
-
```markdown
|
|
6
|
-
<!--section:intro-->
|
|
7
|
-
|
|
8
|
-
This is the introduction section.
|
|
9
|
-
|
|
10
|
-
<!--section:main-->
|
|
11
|
-
|
|
12
|
-
This is the main content.
|
|
13
|
-
|
|
14
|
-
<!--section:footer-->
|
|
15
|
-
|
|
16
|
-
This is the footer.
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
In your template:
|
|
20
|
-
|
|
21
|
-
```nunjucks
|
|
22
|
-
{{ content | section('intro') }}
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
Output:
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
This is the introduction section.
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Multiple Names per Section
|
|
32
|
-
|
|
33
|
-
```markdown
|
|
34
|
-
<!--section:summary,abstract-->
|
|
35
|
-
|
|
36
|
-
This content appears in both 'summary' and 'abstract' sections.
|
|
37
|
-
|
|
38
|
-
<!--section:conclusion-->
|
|
39
|
-
|
|
40
|
-
Final thoughts.
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Both of these work:
|
|
44
|
-
|
|
45
|
-
```nunjucks
|
|
46
|
-
{{ content | section('summary') }}
|
|
47
|
-
{{ content | section('abstract') }}
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
## Real-World Example
|
|
51
|
-
|
|
52
|
-
```markdown
|
|
53
|
-
# Research Paper
|
|
54
|
-
|
|
55
|
-
<!--section:abstract,summary-->
|
|
56
|
-
|
|
57
|
-
A brief overview of the research findings.
|
|
58
|
-
|
|
59
|
-
<!--section:introduction-->
|
|
60
|
-
|
|
61
|
-
Background and context for the research.
|
|
62
|
-
|
|
63
|
-
<!--section:methodology-->
|
|
64
|
-
|
|
65
|
-
How the research was conducted.
|
|
66
|
-
|
|
67
|
-
<!--section:results-->
|
|
68
|
-
|
|
69
|
-
Key findings from the study.
|
|
70
|
-
|
|
71
|
-
<!--section:conclusion,summary-->
|
|
72
|
-
|
|
73
|
-
Summary and implications of the research.
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
Usage:
|
|
77
|
-
|
|
78
|
-
```nunjucks
|
|
79
|
-
<!-- Get full summary (abstract + conclusion) -->
|
|
80
|
-
<div class="summary">
|
|
81
|
-
{{ content | section('summary') }}
|
|
82
|
-
</div>
|
|
83
|
-
|
|
84
|
-
<!-- Get just introduction -->
|
|
85
|
-
<div class="intro">
|
|
86
|
-
{{ content | section('introduction') }}
|
|
87
|
-
</div>
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
## Notes
|
|
91
|
-
|
|
92
|
-
- Section names are **case-insensitive**: `intro`, `INTRO`, and `Intro` are all the same
|
|
93
|
-
- Multiple names can be comma-separated: `<!--section:name1,name2,name3-->`
|
|
94
|
-
- Whitespace around names is trimmed
|
|
95
|
-
- Content extends from the section marker to the next `<!--section*>` or EOF
|
|
96
|
-
- If a section name appears multiple times, all matching sections are concatenated
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|