diff --git a/icons.js b/icons.js index 9bf996c..c342375 100644 --- a/icons.js +++ b/icons.js @@ -1,4 +1,4 @@ -// Generated by build.js at 2025-06-02T19:11:24.112Z +// Generated by build.js at 2024-11-13T00:05:09.492Z export default { "a-b-2": " \n", @@ -55,7 +55,6 @@ export default { "alarm-minus": " \n", "alarm-off": " \n", "alarm-plus": " \n", - "alarm-smoke": " \n", "alarm-snooze": " \n", "alarm": " \n", "album-off": " \n", @@ -158,13 +157,9 @@ export default { "arrow-bar-down": " \n", "arrow-bar-left": " \n", "arrow-bar-right": " \n", - "arrow-bar-to-down-dashed": " \n", "arrow-bar-to-down": " \n", - "arrow-bar-to-left-dashed": " \n", "arrow-bar-to-left": " \n", - "arrow-bar-to-right-dashed": " \n", "arrow-bar-to-right": " \n", - "arrow-bar-to-up-dashed": " \n", "arrow-bar-to-up": " \n", "arrow-bar-up": " \n", "arrow-bear-left-2": " \n", @@ -332,8 +327,8 @@ export default { "article": " \n", "aspect-ratio-off": " \n", "aspect-ratio": " \n", - "assembly-off": " \n", - "assembly": " \n", + "assembly-off": " \n", + "assembly": " \n", "asset": " \n", "asterisk-simple": " \n", "asterisk": " \n", @@ -362,12 +357,9 @@ export default { "backpack": " \n", "backslash": " \n", "backspace": " \n", - "badge-2k": " \n", "badge-3d": " \n", - "badge-3k": " \n", "badge-4k": " \n", - "badge-5k": " \n", - "badge-8k": " \n", + "badge-8k": " \n", "badge-ad-off": " \n", "badge-ad": " \n", "badge-ar": " \n", @@ -510,7 +502,6 @@ export default { "blender": " \n", "blob": " \n", "blockquote": " \n", - "blocks": " \n", "bluetooth-connected": " \n", "bluetooth-off": " \n", "bluetooth-x": " \n", @@ -576,7 +567,6 @@ export default { "bowl-chopsticks": " \n", "bowl-spoon": " \n", "bowl": " \n", - "bowling": " \n", "box-align-bottom-left": " \n", "box-align-bottom-right": " \n", "box-align-bottom": " \n", @@ -998,13 +988,10 @@ export default { "broadcast-off": " \n", "broadcast": " \n", "browser-check": " \n", - "browser-maximize": " \n", - "browser-minus": " \n", "browser-off": " \n", - "browser-plus": " \n", - "browser-share": " \n", + "browser-plus": " \n", "browser-x": " \n", - "browser": " \n", + "browser": " \n", "brush-off": " \n", "brush": " \n", "bubble-minus": " \n", @@ -1065,7 +1052,6 @@ export default { "cactus-off": " \n", "cactus": " \n", "cake-off": " \n", - "cake-roll": " \n", "cake": " \n", "calculator-off": " \n", "calculator": " \n", @@ -1083,7 +1069,7 @@ export default { "calendar-exclamation": " \n", "calendar-heart": " \n", "calendar-minus": " \n", - "calendar-month": " \n", + "calendar-month": " \n", "calendar-off": " \n", "calendar-pause": " \n", "calendar-pin": " \n", @@ -1099,7 +1085,7 @@ export default { "calendar-time": " \n", "calendar-up": " \n", "calendar-user": " \n", - "calendar-week": " \n", + "calendar-week": " \n", "calendar-x": " \n", "calendar": " \n", "camera-ai": " \n", @@ -1132,7 +1118,7 @@ export default { "camper": " \n", "campfire": " \n", "cancel": " \n", - "candle": " \n", + "candle": " \n", "candy-off": " \n", "candy": " \n", "cane": " \n", @@ -1172,23 +1158,11 @@ export default { "carousel-vertical": " \n", "carrot-off": " \n", "carrot": " \n", - "cash-banknote-edit": " \n", - "cash-banknote-heart": " \n", - "cash-banknote-minus": " \n", - "cash-banknote-move-back": " \n", - "cash-banknote-move": " \n", "cash-banknote-off": " \n", - "cash-banknote-plus": " \n", - "cash-banknote": " \n", - "cash-edit": " \n", - "cash-heart": " \n", - "cash-minus": " \n", - "cash-move-back": " \n", - "cash-move": " \n", + "cash-banknote": " \n", "cash-off": " \n", - "cash-plus": " \n", "cash-register": " \n", - "cash": " \n", + "cash": " \n", "cast-off": " \n", "cast": " \n", "cat": " \n", @@ -1211,7 +1185,6 @@ export default { "certificate": " \n", "chair-director": " \n", "chalkboard-off": " \n", - "chalkboard-teacher": " \n", "chalkboard": " \n", "charging-pile": " \n", "chart-arcs-3": " \n", @@ -1561,9 +1534,6 @@ export default { "code-minus": " \n", "code-off": " \n", "code-plus": " \n", - "code-variable-minus": " \n", - "code-variable-plus": " \n", - "code-variable": " \n", "code": " \n", "coffee-off": " \n", "coffee": " \n", @@ -2120,8 +2090,8 @@ export default { "equal": " \n", "eraser-off": " \n", "eraser": " \n", - "error-404-off": " \n", - "error-404": " \n", + "error-404-off": " \n", + "error-404": " \n", "escalator-down": " \n", "escalator-up": " \n", "escalator": " \n", @@ -2135,10 +2105,10 @@ export default { "exposure-0": " \n", "exposure-minus-1": " \n", "exposure-minus-2": " \n", - "exposure-off": " \n", + "exposure-off": " \n", "exposure-plus-1": " \n", "exposure-plus-2": " \n", - "exposure": " \n", + "exposure": " \n", "external-link-off": " \n", "external-link": " \n", "eye-bitcoin": " \n", @@ -2182,7 +2152,7 @@ export default { "feather": " \n", "fence-off": " \n", "fence": " \n", - "ferry": " \n", + "ferry": " ", "fidget-spinner": " \n", "file-3d": " \n", "file-ai": " \n", @@ -2245,7 +2215,6 @@ export default { "file-star": " \n", "file-symlink": " \n", "file-text-ai": " \n", - "file-text-shield": " \n", "file-text-spark": " \n", "file-text": " \n", "file-time": " \n", @@ -2282,27 +2251,6 @@ export default { "file": " \n", "files-off": " \n", "files": " \n", - "filter-2-bolt": " \n", - "filter-2-cancel": " \n", - "filter-2-check": " \n", - "filter-2-code": " \n", - "filter-2-cog": " \n", - "filter-2-discount": " \n", - "filter-2-dollar": " \n", - "filter-2-down": " \n", - "filter-2-edit": " \n", - "filter-2-exclamation": " \n", - "filter-2-minus": " \n", - "filter-2-pause": " \n", - "filter-2-pin": " \n", - "filter-2-plus": " \n", - "filter-2-question": " \n", - "filter-2-search": " \n", - "filter-2-share": " \n", - "filter-2-spark": " \n", - "filter-2-up": " \n", - "filter-2-x": " \n", - "filter-2": " \n", "filter-bolt": " \n", "filter-cancel": " \n", "filter-check": " \n", @@ -2322,7 +2270,6 @@ export default { "filter-question": " \n", "filter-search": " \n", "filter-share": " \n", - "filter-spark": " \n", "filter-star": " \n", "filter-up": " \n", "filter-x": " \n", @@ -2371,7 +2318,7 @@ export default { "flag-x": " \n", "flag": " \n", "flame-off": " \n", - "flame": " \n", + "flame": " \n", "flare": " \n", "flask-2-off": " \n", "flask-2": " \n", @@ -2418,7 +2365,7 @@ export default { "folder-x": " \n", "folder": " \n", "folders-off": " \n", - "folders": " \n", + "folders": " \n", "forbid-2": " \n", "forbid": " \n", "forklift": " \n", @@ -2527,7 +2474,6 @@ export default { "h-6": " \n", "hammer-off": " \n", "hammer": " \n", - "hand-click-off": " \n", "hand-click": " \n", "hand-finger-down": " \n", "hand-finger-left": " \n", @@ -2710,26 +2656,16 @@ export default { "hours-12": " \n", "hours-24": " \n", "html": " \n", - "http-connect-off": " \n", - "http-connect": " \n", - "http-delete-off": " \n", - "http-delete": " \n", - "http-get-off": " \n", + "http-connect": " \n", + "http-delete": " \n", "http-get": " \n", - "http-head-off": " \n", "http-head": " \n", - "http-options-off": " \n", - "http-options": " \n", - "http-patch-off": " \n", + "http-options": " \n", "http-patch": " \n", - "http-post-off": " \n", - "http-post": " \n", - "http-put-off": " \n", + "http-post": " \n", "http-put": " \n", - "http-que-off": " \n", - "http-que": " \n", - "http-trace-off": " \n", - "http-trace": " \n", + "http-que": " \n", + "http-trace": " \n", "ice-cream-2": " \n", "ice-cream-off": " \n", "ice-cream": " \n", @@ -3180,7 +3116,6 @@ export default { "math-y-minus-y": " \n", "math-y-plus-y": " \n", "math": " \n", - "matrix": " \n", "maximize-off": " \n", "maximize": " \n", "meat-off": " \n", @@ -3302,13 +3237,7 @@ export default { "mist": " \n", "mobiledata-off": " \n", "mobiledata": " \n", - "moneybag-edit": " \n", - "moneybag-heart": " \n", - "moneybag-minus": " \n", - "moneybag-move-back": " \n", - "moneybag-move": " \n", - "moneybag-plus": " \n", - "moneybag": " \n", + "moneybag": " \n", "monkeybar": " \n", "mood-angry": " \n", "mood-annoyed-2": " \n", @@ -3957,7 +3886,6 @@ export default { "repeat-once": " \n", "repeat": " \n", "replace-off": " \n", - "replace-user": " \n", "replace": " \n", "report-analytics": " \n", "report-medical": " \n", @@ -4097,8 +4025,8 @@ export default { "search": " \n", "section-sign": " \n", "section": " \n", - "seedling-off": " \n", - "seedling": " \n", + "seeding-off": " \n", + "seeding": " \n", "select-all": " \n", "select": " \n", "selector": " \n", @@ -4293,7 +4221,7 @@ export default { "spade": " \n", "sparkles": " \n", "speakerphone": " \n", - "speedboat": " \n", + "speedboat": " \n", "sphere-off": " \n", "sphere-plus": " \n", "sphere": " \n", @@ -4319,7 +4247,6 @@ export default { "square-chevrons-left": " \n", "square-chevrons-right": " \n", "square-chevrons-up": " \n", - "square-dashed": " \n", "square-dot": " \n", "square-f0": " \n", "square-f1": " \n", @@ -4514,7 +4441,6 @@ export default { "swords": " \n", "table-alias": " \n", "table-column": " \n", - "table-dashed": " \n", "table-down": " \n", "table-export": " \n", "table-heart": " \n", @@ -4659,7 +4585,7 @@ export default { "traffic-cone": " \n", "traffic-lights-off": " \n", "traffic-lights": " \n", - "train": " \n", + "train": " \n", "transaction-bitcoin": " \n", "transaction-dollar": " \n", "transaction-euro": " \n", @@ -4721,7 +4647,6 @@ export default { "u-turn-right": " \n", "ufo-off": " \n", "ufo": " \n", - "uhd": " \n", "umbrella-2": " \n", "umbrella-closed-2": " \n", "umbrella-closed": " \n", @@ -4866,8 +4791,6 @@ export default { "webhook-off": " \n", "webhook": " \n", "weight": " \n", - "wheat-off": " \n", - "wheat": " \n", "wheel": " \n", "wheelchair-off": " \n", "wheelchair": " \n", diff --git a/package-lock.json b/package-lock.json index 3a7b507..a74821a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,16 @@ { "name": "@cdransf/eleventy-plugin-tabler-icons", - "version": "2.13.1", + "version": "2.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@cdransf/eleventy-plugin-tabler-icons", - "version": "2.13.1", + "version": "2.2.0", "license": "MIT", "devDependencies": { "@11ty/eleventy": "v3.0.0", - "@tabler/icons": "^3.34.0" + "@tabler/icons": "^3.22.0" } }, "node_modules/@11ty/dependency-tree": { @@ -349,9 +349,9 @@ } }, "node_modules/@tabler/icons": { - "version": "3.34.0", - "resolved": "https://registry.npmjs.org/@tabler/icons/-/icons-3.34.0.tgz", - "integrity": "sha512-jtVqv0JC1WU2TTEBN32D9+R6mc1iEBuPwLnBsWaR02SIEciu9aq5806AWkCHuObhQ4ERhhXErLEK7Fs+tEZxiA==", + "version": "3.22.0", + "resolved": "https://registry.npmjs.org/@tabler/icons/-/icons-3.22.0.tgz", + "integrity": "sha512-IfgGzhFph5OBr2wTieWL/hyAs0FThnq9O155a6kfGYxqx7h5LQw91wnRswhEaGhXCcfmR7ZVDUr9H+x4b9Pb8g==", "dev": true, "license": "MIT", "funding": { diff --git a/package.json b/package.json index 94dede0..6881b0d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cdransf/eleventy-plugin-tabler-icons", - "version": "2.13.1", + "version": "2.2.0", "description": "Shortcodes to add Tabler icons to your Eleventy projects", "type": "module", "main": "tablericons.js", @@ -25,15 +25,15 @@ }, "repository": { "type": "git", - "url": "git+https://git.apps.coryd.dev/cdransf/eleventy-plugin-tabler-icons.git" + "url": "git+https://github.com/cdransf/eleventy-plugin-tabler-icons.git" }, - "homepage": "https://git.apps.coryd.dev/cdransf/eleventy-plugin-tabler-icons#readme", + "homepage": "https://github.com/cdransf/eleventy-plugin-tabler-icons#readme", "bugs": { - "url": "https://git.apps.coryd.dev/cdransf/eleventy-plugin-tabler-icons/issues" + "url": "https://github.com/cdransf/eleventy-plugin-tabler-icons/issues" }, "license": "MIT", "devDependencies": { "@11ty/eleventy": "v3.0.0", - "@tabler/icons": "^3.34.0" + "@tabler/icons": "^3.22.0" } } diff --git a/tablericons.js b/tablericons.js index 4cb477e..b959cba 100644 --- a/tablericons.js +++ b/tablericons.js @@ -1,58 +1,48 @@ -import ICONS from './icons.js'; +import ICONS from './icons.js' const tablericons = (eleventyConfig, config = {}) => { - const { className = '', errorOnMissing = false } = config; + const { className = '', errorOnMissing = false } = config - const renderIcon = (context = {}, name, alt = '', attrs = {}) => { - const contents = ICONS[name]; + const renderIcon = (context = this, name, alt, attrs) => { + const contents = ICONS[name] if (!contents) { - handleMissingIcon(name, context.page?.inputPath); - return ''; + handleMissingIcon(name, context.page.inputPath) + return '' } - return `${buildHead(alt, className, name, attrs)}${contents}${ICONS.TAIL}`; - }; + return `${head(alt, className, name, attrs)}${contents}${ICONS.TAIL}` + } const handleMissingIcon = (name, inputPath) => { - const message = `No tablericon found for name '${name}'`; + const message = `No tablericons found for name '${name}'` if (errorOnMissing) { - throw new Error(message); + throw new Error(message) } else { - console.warn(`${message}${inputPath ? ` in ${inputPath}` : ''}`); + console.warn(`${message} in ${inputPath}`) } - }; - - eleventyConfig.addShortcode('tablericon', function (name, alt, attrs) { - return renderIcon(this, name, alt, attrs); - }); -}; - -const buildHead = (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(([key, val]) => (key && val ? ` ${key}="${val}"` : '')) - .join(''); } - return `${output}>`; -}; - -export function renderTablerIcon(name, alt = '', attrs = {}, options = {}) { - const context = { page: { inputPath: options.inputPath || '' } }; - const contents = ICONS[name]; - if (!contents) { - console.warn(`No tablericon found for name '${name}'${options.inputPath ? ` in ${options.inputPath}` : ''}`); - return ''; - } - - return `${buildHead(alt, options.className || '', name, attrs)}${contents}${ICONS.TAIL}`; + // Register shortcode for Eleventy 3.0 + eleventyConfig.addShortcode('tablericon', (name, alt, attrs) => { + return renderIcon(this, name, alt, attrs) + }) } -export default tablericons; +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 \ No newline at end of file