<commit_before>const Image = require('@11ty/eleventy-img');

module.exports = async (src, alt, className, outputFormat = 'jpeg') => {
  const stats = await Image(src, {
    cacheDuration: '12w',
    formats: [outputFormat],
    outputDir: '_site/assets/avatar/',
    widths: [96],
  });

  const classAttr = className ? `class="${className}"` : '';

  const props = stats[outputFormat].pop();

  if (alt === undefined) {
    throw new Error(`Missing ALT attribute from: ${src}`);
  }

  return `<img ${classAttr} src="${props.outputPath.replace('_site', '')}" alt="${alt}" loading="lazy">`;
};<commit_msg>Fix eleventy-img fetch 404 issue<commit_after>const Image = require('@11ty/eleventy-img');

module.exports = async (src, alt, className, outputFormat = 'jpeg') => {
  if (alt === undefined) {
    throw new Error(`Missing ALT attribute from: ${src}`);
  }

  const classAttr = className ? `class="${className}"` : '';

  try {
    const stats = await Image(src, {
      cacheDuration: '12w',
      formats: [outputFormat],
      outputDir: '_site/assets/avatar/',
      widths: [96],
    });

    const props = stats[outputFormat].pop();

    return `<img ${classAttr} src="${props.outputPath.replace('_site', '')}" alt="${alt}" loading="lazy">`;
  } catch (err) {
    // eslint-disable-next-line no-console
    console.error(err);

    return '';
  }
};
{'fraction_non_alphanumeric': 0.19440353460972018, 'fraction_numerical': 0.011045655375552283, 'mean_word_length': 3.8362989323843415, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7033341', 'n_tokens_mistral': 452, 'n_tokens_neox': 435, 'n_words': 101}