diff --git a/README.md b/README.md
index 4631324..35ab089 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ Shortcodes to add [tabler icons](https://tabler-icons.io) to your [Eleventy](htt
Install the package:
```sh
-npm i -D @cdransf/eleventy-plugin-tablericons
+npm i -D @cdransf/eleventy-plugin-tabler-icons
```
Then add the plugin to your `.eleventy.js` file:
@@ -19,7 +19,7 @@ Then add the plugin to your `.eleventy.js` file:
```js
// .eleventy.js
module.exports = eleventyConfig => {
- eleventyConfig.addPlugin(require('@cdransf/eleventy-plugin-tablericons'));
+ eleventyConfig.addPlugin(require('@cdransf/eleventy-plugin-tabler-icons'));
}
```
@@ -40,7 +40,7 @@ Args: `name: string`, `alt?: string`
## Configuration
-`eleventy-plugin-tablericons` offers a few options on a configuration object passed to Eleventy's `addPlugin()`:
+`@cdransf/eleventy-plugin-tabler-icons` offers a few options on a configuration object passed to Eleventy's `addPlugin()`:
- `className?: string` Adds a class to all tabler icons
- `errorOnMissing: boolean` (default: `false`) Throw an error when passed an invalid style/name or invalid attribute
@@ -50,7 +50,7 @@ Pass the configuration object when adding the plugin:
```js
// .eleventy.js
module.exports = eleventyConfig => {
- eleventyConfig.addPlugin(require('@cdransf/eleventy-plugin-tablericons'), {
+ eleventyConfig.addPlugin(require('@cdransf/eleventy-plugin-tabler-icons'), {
className: 'icon',
errorOnMissing: true
});
diff --git a/build.js b/build.js
index 6ebd8a7..37e76bb 100644
--- a/build.js
+++ b/build.js
@@ -1,28 +1,36 @@
-const fs = require('fs');
-const path = `./node_modules/@tabler/icons/icons/outline/`;
-const fileNames = fs.readdirSync(path);
-const object = {};
+import { readdirSync, readFileSync, writeFileSync } from 'fs'
+import path from 'path'
+
+const ICONS_DIR = path.join('node_modules', '@tabler', 'icons', 'icons', 'outline')
const CONTENTS = {
- HEAD: "",
-};
+ HEAD: `'
+}
+const object = {}
-fileNames.forEach((filename) => {
- const contents = fs
- .readFileSync(path + filename)
- .toString()
- .trimEnd();
- const lines = contents.split("\n");
- const guts = lines
- .slice(1, lines.length - 1)
- .join("")
- .replace(/\ \ /g, "");
- if (object) object[filename.slice(0, -4)] = guts;
-});
+try {
+ const fileNames = readdirSync(ICONS_DIR)
-fs.writeFileSync(
- "./icons.js",
- `// Generated by build.js at ${new Date().toISOString()}\n\nmodule.exports = ${JSON.stringify(
- {...object, HEAD: CONTENTS['HEAD'], TAIL: CONTENTS['TAIL']}
- )};\n`
-);
+ fileNames.forEach((filename) => {
+ const filePath = path.join(ICONS_DIR, filename)
+ const contents = readFileSync(filePath, 'utf8').trim()
+
+ const guts = contents
+ .replace(/^