You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+19-1Lines changed: 19 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -138,9 +138,27 @@ Which will render the following (assuming that `globalClasses: "svgicon", defaul
138
138
</svg>
139
139
```
140
140
141
+
### SVG id naming convention
142
+
```
143
+
📂assets
144
+
┣ 📂svg
145
+
┣ 📜 item.svg
146
+
┣ 📂 sub_dir_1
147
+
┃ ┗ 📜 item-1.svg
148
+
┗ 📂 sub_dir_2
149
+
┗ 📂 sub_sub_dir_2
150
+
┗ 📜 example item 2.svg
151
+
```
152
+
For a directory structure as above, the respective SVG ids generated are as follows:
153
+
```js
154
+
svg "item"// no subdirectory prefix
155
+
svg "sub_dir_1--item-1"// one level subdirectory with '--' prefix
156
+
svg "sub_dir_2--sub_sub_dir_2--example_item_2"// two level subdirectory with '--' prefix, also convert spaces into '_'
157
+
```
158
+
141
159
### Using your own shortcode to render SVGs
142
160
143
-
You can write your own SVG shortcode if you prefer. To make sure the SVG is referenced correctly, you can use the snippet below to start. `#svg-` is the prefix created by svg-sprite and `name` would be the filename of the SVG without the `.svg` extension.
161
+
You can write your own SVG shortcode if you prefer. To make sure the SVG is referenced correctly, you can use the snippet below to start. `#svg-` is the prefix created by svg-sprite and `name` would be the filename of the SVG without the `.svg` extension (also refer to [SVG id naming convention](#svg-id-naming-convention) for edge cases and other uses).
144
162
145
163
```js
146
164
eleventyConfig.addShortcode("icon", function (name) {
0 commit comments