back to commonJS for this one
This commit is contained in:
parent
c0a23b6a5a
commit
e0b6131921
1 changed files with 5 additions and 8 deletions
|
|
@ -1,11 +1,8 @@
|
||||||
<!-- by Ryan Mulligan: https://github.com/hexagoncircle/start-me-up/blob/main/src/_includes/inline-svg.webc -->
|
|
||||||
|
|
||||||
<script webc:type="render" webc:is="template">
|
<script webc:type="render" webc:is="template">
|
||||||
export default async function () {
|
const Image = require('@11ty/eleventy-img');
|
||||||
const {default: slugify} = await import('slugify');
|
const {optimize} = require('svgo');
|
||||||
const {default: Image} = await import('@11ty/eleventy-img');
|
|
||||||
const {optimize} = await import('svgo');
|
|
||||||
|
|
||||||
|
module.exports = async function () {
|
||||||
const meta = await Image(this.src, {
|
const meta = await Image(this.src, {
|
||||||
formats: ['svg'],
|
formats: ['svg'],
|
||||||
dryRun: true
|
dryRun: true
|
||||||
|
|
@ -20,7 +17,7 @@
|
||||||
|
|
||||||
for (const prop in this.webc.attributes) {
|
for (const prop in this.webc.attributes) {
|
||||||
if (!excludeAttributes.includes(prop)) {
|
if (!excludeAttributes.includes(prop)) {
|
||||||
const attribute = slugify(prop, {lower: true, strict: true, remove: /[*+~.()'"!:@]/g});
|
const attribute = this.slugify(prop, {decamelize: true});
|
||||||
const value = this.webc.attributes[prop];
|
const value = this.webc.attributes[prop];
|
||||||
|
|
||||||
arr.push({[attribute]: value});
|
arr.push({[attribute]: value});
|
||||||
|
|
@ -42,5 +39,5 @@
|
||||||
const result = optimize(svgContents, {plugins});
|
const result = optimize(svgContents, {plugins});
|
||||||
|
|
||||||
return result.data;
|
return result.data;
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue