@anydigital/11ty-bricks 1.0.0-alpha.5 → 1.0.0-alpha.6
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 +3 -3
- package/package.json +1 -1
- package/src/bricksRegistry.js +4 -4
package/README.md
CHANGED
|
@@ -102,7 +102,7 @@ When building reusable components (bricks) in Eleventy, you often need to includ
|
|
|
102
102
|
|
|
103
103
|
**How it works:**
|
|
104
104
|
|
|
105
|
-
1. Use the `
|
|
105
|
+
1. Use the `bricksRegistry` shortcode in your base template to mark where dependencies should be injected
|
|
106
106
|
2. Use the `brick` shortcode to register and render brick components that declare their dependencies
|
|
107
107
|
3. The system automatically collects all dependencies and injects them when the page is built
|
|
108
108
|
|
|
@@ -120,13 +120,13 @@ export default function(eleventyConfig) {
|
|
|
120
120
|
}
|
|
121
121
|
```
|
|
122
122
|
|
|
123
|
-
2. Add the `
|
|
123
|
+
2. Add the `bricksRegistry` shortcode in your base template (typically in the `<head>` section):
|
|
124
124
|
|
|
125
125
|
```njk
|
|
126
126
|
<head>
|
|
127
127
|
<meta charset="UTF-8">
|
|
128
128
|
<title>My Site</title>
|
|
129
|
-
{%
|
|
129
|
+
{% bricksRegistry %}
|
|
130
130
|
<!-- Other head content -->
|
|
131
131
|
</head>
|
|
132
132
|
```
|
package/package.json
CHANGED
package/src/bricksRegistry.js
CHANGED
|
@@ -53,13 +53,13 @@ export function bricksRegistry(eleventyConfig) {
|
|
|
53
53
|
return '';
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
//
|
|
57
|
-
eleventyConfig.addShortcode("
|
|
56
|
+
// bricksRegistry shortcode: outputs placeholder and base dependencies
|
|
57
|
+
eleventyConfig.addShortcode("bricksRegistry", function(dependencies = []) {
|
|
58
58
|
const registry = getPageRegistry(this.page);
|
|
59
59
|
|
|
60
60
|
// Register root dependencies if provided (categorized later in transform)
|
|
61
|
-
if (
|
|
62
|
-
|
|
61
|
+
if (dependencies && Array.isArray(dependencies)) {
|
|
62
|
+
dependencies.forEach(dep => {
|
|
63
63
|
registry.dependencies.add(dep);
|
|
64
64
|
});
|
|
65
65
|
}
|