Skip to content

Commit

Permalink
Clean up the config file... again?
Browse files Browse the repository at this point in the history
  • Loading branch information
wesley-dean-gsa committed Aug 2, 2024
1 parent 5f428cb commit 9c30877
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions config/index.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,35 @@
const path = require('path');
const Image = require('@11ty/eleventy-img');

async function imageWithClassShortcode(
src,
cls,
alt,
containFit
) {
let pathPrefix = '';
const path = require("path");
const Image = require("@11ty/eleventy-img");

async function imageWithClassShortcode(src, cls, alt, containFit) {
let pathPrefix = "";
let style;

if (process.env.BASEURL) {
pathPrefix = process.env.BASEURL
pathPrefix = process.env.BASEURL;
}

const ext = path.extname(src);
const fileType = ext.replace('.', '');
const fileType = ext.replace(".", "");

const metadata = await Image(src, {
formats: [fileType],
outputDir: './_site/img/',
outputDir: "./_site/img/",
});

const data = metadata[fileType] ? metadata[fileType][0] : metadata.jpeg[0];

if (containFit) {
style = 'style="object-fit:contain;"';
}
return `<img src="${pathPrefix}${data.url}" class="${cls}" alt="${alt}" loading="lazy" decoding="async" ${style}>`;
};

}

async function imageShortcode(src, alt) {
return await imageWithClassShortcode(src, '', alt)
};
return await imageWithClassShortcode(src, "", alt);
}

module.exports = {
imageWithClassShortcode,
imageShortcode
}
imageShortcode,
};

0 comments on commit 9c30877

Please sign in to comment.