Skip to content

Commit

Permalink
back to commonJS for this one
Browse files Browse the repository at this point in the history
  • Loading branch information
madrilene committed Jul 21, 2024
1 parent c0a23b6 commit e0b6131
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/_includes/webc/custom-svg.webc
Original file line number Diff line number Diff line change
@@ -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">
export default async function () {
const {default: slugify} = await import('slugify');
const {default: Image} = await import('@11ty/eleventy-img');
const {optimize} = await import('svgo');
const Image = require('@11ty/eleventy-img');
const {optimize} = require('svgo');

module.exports = async function () {
const meta = await Image(this.src, {
formats: ['svg'],
dryRun: true
Expand All @@ -20,7 +17,7 @@

for (const prop in this.webc.attributes) {
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];

arr.push({[attribute]: value});
Expand All @@ -42,5 +39,5 @@
const result = optimize(svgContents, {plugins});

return result.data;
}
};
</script>

0 comments on commit e0b6131

Please sign in to comment.