Compare commits

..

No commits in common. "main" and "v2.4" have entirely different histories.
main ... v2.4

5 changed files with 4929 additions and 5023 deletions

View file

@ -14,11 +14,8 @@ try {
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, ' ')
const lines = contents.split('\n')
const guts = lines.slice(1, -1).join(' ').replace(/\s{2,}/g, ' ')
object[filename.slice(0, -4)] = guts
})

9847
icons.js

File diff suppressed because it is too large Load diff

12
package-lock.json generated
View file

@ -1,16 +1,16 @@
{
"name": "@cdransf/eleventy-tabler-icons-filled",
"version": "2.13.1",
"version": "2.1.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@cdransf/eleventy-tabler-icons-filled",
"version": "2.13.1",
"version": "2.1.0",
"license": "MIT",
"devDependencies": {
"@11ty/eleventy": "v3.0.0",
"@tabler/icons": "^3.34.0"
"@tabler/icons": "^3.20.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.20.0",
"resolved": "https://registry.npmjs.org/@tabler/icons/-/icons-3.20.0.tgz",
"integrity": "sha512-nXSeUzsCOxX/Of+kdUVQfxL9bG+ck8XCWNf9dGSpE+nhVexRwk/4HiDQDxFDysfT7vfgSut6GXnrZsU5M5dSlA==",
"dev": true,
"license": "MIT",
"funding": {

View file

@ -1,6 +1,6 @@
{
"name": "@cdransf/eleventy-tabler-icons-filled",
"version": "2.13.1",
"version": "2.1.0",
"description": "Shortcodes to add filled 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-tabler-icons-filled.git"
"url": "git+https://github.com/cdransf/eleventy-tabler-icons-filled.git"
},
"homepage": "https://git.apps.coryd.dev/cdransf/eleventy-tabler-icons-filled#readme",
"homepage": "https://github.com/cdransf/eleventy-tabler-icons-filled#readme",
"bugs": {
"url": "https://git.apps.coryd.dev/cdransf/eleventy-tabler-icons-filled/issues"
"url": "https://github.com/cdransf/eleventy-tabler-icons-filled/issues"
},
"license": "MIT",
"devDependencies": {
"@11ty/eleventy": "v3.0.0",
"@tabler/icons": "^3.34.0"
"@tabler/icons": "^3.20.0"
}
}

View file

@ -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