@anydigital/11ty-bricks 1.0.0-alpha.3 → 1.0.0-alpha.4

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 CHANGED
@@ -102,6 +102,48 @@ Use {{ variable }} to output variables.
102
102
 
103
103
  Would try to process `{{ variable }}` as a template variable. With `autoRaw`, it displays exactly as written.
104
104
 
105
+ ## Available Bricks (Components)
106
+
107
+ ### Navigation Macro (`_nav.njk`)
108
+
109
+ A reusable Nunjucks macro for rendering navigation menus with proper accessibility attributes. This macro works seamlessly with the [11ty Navigation Plugin](https://www.11ty.dev/docs/plugins/navigation/).
110
+
111
+ **Usage:**
112
+
113
+ 1. Import the macro in your template:
114
+
115
+ ```njk
116
+ {% from "bricks/_nav.njk" import render as renderNav %}
117
+ ```
118
+
119
+ 2. Call the macro with your navigation data:
120
+
121
+ ```njk
122
+ {{ renderNav(collections.all | eleventyNavigation, page) }}
123
+ ```
124
+
125
+ **Parameters:**
126
+
127
+ - `navPages`: Array of navigation entries (typically from `eleventyNavigation` filter)
128
+ - `curPage`: Current page object (use Eleventy's `page` variable)
129
+
130
+ **Features:**
131
+
132
+ - Renders a semantic `<nav>` element
133
+ - Automatically adds `aria-current="page"` to the current page link for accessibility
134
+ - Clean, minimal markup ready for styling
135
+ - Works with nested navigation structures from the 11ty Navigation Plugin
136
+
137
+ **Example Output:**
138
+
139
+ ```html
140
+ <nav>
141
+ <a href="/">Home</a>
142
+ <a href="/about/">About</a>
143
+ <a href="/contact/" aria-current="page">Contact</a>
144
+ </nav>
145
+ ```
146
+
105
147
  ## CLI Helper Commands
106
148
 
107
149
  After installing this package, the `download-files` command becomes available:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anydigital/11ty-bricks",
3
- "version": "1.0.0-alpha.3",
3
+ "version": "1.0.0-alpha.4",
4
4
  "description": "A collection of helpful utilities and filters for Eleventy (11ty)",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -11,7 +11,7 @@
11
11
  }
12
12
  },
13
13
  "bin": {
14
- "download-files": "./src/cli/download-files.js"
14
+ "download-files": "src/cli/download-files.js"
15
15
  },
16
16
  "files": [
17
17
  "src"
@@ -0,0 +1,10 @@
1
+ {% macro render(navPages, curPage) %}
2
+ {# https://www.11ty.dev/docs/plugins/navigation/#bring-your-own-html-render-the-menu-items-manually #}
3
+ <nav>
4
+ {%- for entry in navPages %}
5
+ <a href="{{ entry.url }}" {{ 'aria-current="page"' | safe if entry.url == curPage.url }}>
6
+ {{- entry.title -}}
7
+ </a>
8
+ {%- endfor %}
9
+ </nav>
10
+ {% endmacro %}