Compare commits

..

40 commits
v1.1.0 ... main

Author SHA1 Message Date
c598e946b9
chore: update repo url 2025-03-28 08:32:00 -07:00
b825a2577f
chore: update icons 2025-03-04 17:04:16 -08:00
06be04b053
chore: update icons 2025-02-07 09:19:23 -08:00
21e29e3d8f
chore: update icons 2025-01-21 16:22:04 -08:00
73dcd1769e
chore: update icons 2025-01-08 06:44:15 -08:00
411f26fc84
chore: update icons 2025-01-06 11:47:17 -08:00
e93e8dc1f6
chore: update icons 2024-12-16 09:14:02 -08:00
1eba931ab2
chore: update icons 2024-12-15 12:06:37 -08:00
65971a84c0
chore: update icons 2024-12-02 15:51:04 -08:00
f3caf901cf
chore: update icons 2024-11-28 12:07:46 -08:00
60d4e420ab
chore: update icons 2024-11-12 16:05:17 -08:00
cc366297a7
fix: build script 2024-10-31 04:34:04 -07:00
ae77ce1387
chore: update icons 2024-10-23 06:43:38 -07:00
7e978a7038
fix: build script 2024-10-02 20:35:19 -07:00
3e2999c3e2
fix: build script 2024-10-02 20:30:08 -07:00
9e60d42068
fix: type 2024-10-02 20:21:49 -07:00
f030e40af4
chore: upgrade to 11ty v3 2024-10-02 19:43:47 -07:00
f1029ac0f5
chore: update icons 2024-09-28 07:47:44 -07:00
1566b1e138
chore: update icons 2024-09-26 16:18:20 -07:00
3ecafeee6d
chore: update icons 2024-09-15 11:28:43 -07:00
899e0c1e37
chore: update icons 2024-09-10 14:41:56 -07:00
8fe8a4da5e
chore: update icons 2024-09-08 16:54:52 -07:00
9b0ab6130a
chore: update icons 2024-08-27 15:16:24 -07:00
e3d24937ce
chore: update icons 2024-08-08 15:54:37 -07:00
5bb07c142f
chore: update icons 2024-07-16 08:25:38 -07:00
f8478084e4
chore: update icons 2024-07-11 14:16:20 -07:00
1f88cdad4d
chore: update icons 2024-07-02 19:33:44 -07:00
6742bdd681
chore: update icons 2024-06-25 14:56:03 -07:00
b29d79d399
chore: update deps 2024-06-18 19:29:23 -07:00
f5a490905a
Merge pull request #4 from cdransf/dependabot/npm_and_yarn/ws-8.17.1
chore(deps-dev): bump ws from 8.17.0 to 8.17.1
2024-06-18 19:28:09 -07:00
dependabot[bot]
2ce1350d34
chore(deps-dev): bump ws from 8.17.0 to 8.17.1
Bumps [ws](https://github.com/websockets/ws) from 8.17.0 to 8.17.1.
- [Release notes](https://github.com/websockets/ws/releases)
- [Commits](https://github.com/websockets/ws/compare/8.17.0...8.17.1)

---
updated-dependencies:
- dependency-name: ws
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-19 02:27:10 +00:00
59ce6ff931
Merge pull request #2 from cdransf/dependabot/npm_and_yarn/braces-3.0.3
chore(deps-dev): bump braces from 3.0.2 to 3.0.3
2024-06-14 08:22:36 -07:00
1436d6c469
Merge pull request #3 from cdransf/dependabot/npm_and_yarn/pug-3.0.3
chore(deps-dev): bump pug from 3.0.2 to 3.0.3
2024-06-14 08:22:25 -07:00
dependabot[bot]
0db6e8733e
chore(deps-dev): bump pug from 3.0.2 to 3.0.3
Bumps [pug](https://github.com/pugjs/pug) from 3.0.2 to 3.0.3.
- [Release notes](https://github.com/pugjs/pug/releases)
- [Commits](https://github.com/pugjs/pug/compare/pug@3.0.2...pug@3.0.3)

---
updated-dependencies:
- dependency-name: pug
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-14 15:21:26 +00:00
dependabot[bot]
f6ceaf32b7
chore(deps-dev): bump braces from 3.0.2 to 3.0.3
Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3.
- [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md)
- [Commits](https://github.com/micromatch/braces/compare/3.0.2...3.0.3)

---
updated-dependencies:
- dependency-name: braces
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-14 15:21:25 +00:00
2e33ac630e
chore: update icons 2024-06-14 08:20:49 -07:00
7735c734db
chore: update icons 2024-05-23 16:25:32 -07:00
6067e3980d
v1.4.0: update icons 2024-05-18 08:33:00 -07:00
74f9c6d0e6
chore: new icons 2024-05-02 10:59:08 -07:00
Cory Dransfeldt
b4c3355354
chore: update icons 2024-04-16 15:03:37 -07:00
5 changed files with 6094 additions and 1001 deletions

View file

@ -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: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" stroke-width=\"2\" stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\">",
TAIL: "</svg>",
};
HEAD: `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">`,
TAIL: '</svg>'
}
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(/^<svg[^>]*>/, '')
.replace(/<\/svg>$/, '')
.replace(/\s{2,}/g, ' ')
object[filename.slice(0, -4)] = guts
})
const output = `// Generated by build.js at ${new Date().toISOString()}
export default ${JSON.stringify({ ...object, HEAD: CONTENTS.HEAD, TAIL: CONTENTS.TAIL }, null, 2)};
`
writeFileSync('./icons.js', output)
console.log('Icons successfully generated and saved to icons.js!')
} catch (err) {
console.error('Error processing icons:', err)
}

4943
icons.js

File diff suppressed because one or more lines are too long

2000
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,8 @@
{
"name": "@cdransf/eleventy-plugin-tabler-icons",
"version": "1.1.0",
"version": "2.11.1",
"description": "Shortcodes to add Tabler icons to your Eleventy projects",
"type": "module",
"main": "tablericons.js",
"files": [
"tablericons.js",
@ -18,21 +19,21 @@
"tabler-icons"
],
"author": {
"email": "coryd@hey.com",
"email": "hi@coryd.dev",
"name": "Cory Dransfeldt",
"url": "https://coryd.dev"
},
"repository": {
"type": "git",
"url": "git+https://github.com/cdransf/eleventy-plugin-tabler-icons.git"
"url": "git+https://git.apps.coryd.dev/cdransf/eleventy-plugin-tabler-icons.git"
},
"homepage": "https://github.com/cdransf/eleventy-plugin-tabler-icons#readme",
"homepage": "https://git.apps.coryd.dev/cdransf/eleventy-plugin-tabler-icons#readme",
"bugs": {
"url": "https://github.com/cdransf/eleventy-plugin-tabler-icons/issues"
"url": "https://git.apps.coryd.dev/cdransf/eleventy-plugin-tabler-icons/issues"
},
"license": "MIT",
"devDependencies": {
"@11ty/eleventy": "^2.0.1",
"@tabler/icons": "^3.1.0"
"@11ty/eleventy": "v3.0.0",
"@tabler/icons": "^3.31.0"
}
}

View file

@ -1,55 +1,48 @@
const ICONS = require("./icons");
import ICONS from './icons.js'
const initialConfig = {
className: "",
errorOnMissing: false,
};
const tablericons = (eleventyConfig, config = {}) => {
const { className = '', errorOnMissing = false } = config
module.exports = function tablericons(eleventyConfig, config = initialConfig) {
function tablericons(context = this, name, alt) {
const contents = ICONS[name];
const renderIcon = (context = this, name, alt, attrs) => {
const contents = ICONS[name]
if (!contents) {
const message = `No tablericons found for name "${name}"`;
if (config.errorOnMissing) {
throw new Error(message);
} else {
console.warn(message + ` in ${context.page.inputPath}`);
return "";
}
handleMissingIcon(name, context.page.inputPath)
return ''
}
if (!contents) return "";
return `${head(alt, config.className, name)}${contents}${
ICONS.TAIL
}`;
return `${head(alt, className, name, attrs)}${contents}${ICONS.TAIL}`
}
eleventyConfig.addShortcode("tablericon", function (name, alt, attrs) {
return tablericons(this, name, alt, attrs);
});
};
function head(alt, className, iconName, attrs) {
let output = ICONS.HEAD.slice(0, -1); // Open tag
if (!alt) output += ` aria-hidden="true"`;
if (className) output += ` class="${className}"`;
output += ` data-tablericon-name="${iconName}"`;
if (attrs) {
if (typeof attrs === "string") {
output += ` ${attrs}`;
const handleMissingIcon = (name, inputPath) => {
const message = `No tablericons found for name '${name}'`
if (errorOnMissing) {
throw new Error(message)
} else {
Object.entries(attrs).forEach(([property, value]) => {
if (property && value) {
output += ` ${property}="${value}"`;
}
});
console.warn(`${message} in ${inputPath}`)
}
}
output += ">"; // Close tag
if (alt) output += `<title>${alt}</title>`;
return output;
// Register shortcode for Eleventy 3.0
eleventyConfig.addShortcode('tablericon', (name, alt, attrs) => {
return renderIcon(this, name, alt, attrs)
})
}
const head = (alt, className, iconName, attrs) => {
let output = `${ICONS.HEAD.slice(0, -1)} aria-hidden='true'`
if (className) output += ` class='${className}'`
output += ` data-tablericon-name='${iconName}'`
if (typeof attrs === 'string') {
output += ` ${attrs}`
} else if (attrs && typeof attrs === 'object') {
output += Object.entries(attrs)
.map(([property, value]) => (property && value ? ` ${property}='${value}'` : ''))
.join('')
}
return `${output}>`
}
export default tablericons