style: 🎨 extract map function for better readability
This commit is contained in:
parent
019351fd35
commit
5755823792
1 changed files with 6 additions and 2 deletions
|
@ -17,6 +17,8 @@ const IMAGE_ATTR_SIZES = [
|
||||||
{ minw: null, size: 'calc(100vw - 3rem)' }
|
{ minw: null, size: 'calc(100vw - 3rem)' }
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const getAttrSizes = ({ minw, size }) => (minw ? `(min-width: ${minw}) ${size}` : size);
|
||||||
|
|
||||||
const IMAGE_TRANSFORM_OPTS = {
|
const IMAGE_TRANSFORM_OPTS = {
|
||||||
widths: [...IMAGE_COMPUTED_WIDTHS, 'auto'],
|
widths: [...IMAGE_COMPUTED_WIDTHS, 'auto'],
|
||||||
formats: ['avif', 'webp', 'auto'],
|
formats: ['avif', 'webp', 'auto'],
|
||||||
|
@ -27,11 +29,13 @@ const IMAGE_TRANSFORM_OPTS = {
|
||||||
defaultAttributes: {
|
defaultAttributes: {
|
||||||
loading: 'lazy',
|
loading: 'lazy',
|
||||||
decoding: 'async',
|
decoding: 'async',
|
||||||
sizes: IMAGE_ATTR_SIZES.map(({ minw, size }) => (minw ? `(min-width: ${minw}) ${size}` : size)).join(', ')
|
sizes: IMAGE_ATTR_SIZES.map(getAttrSizes).join(', ')
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const BASE = env.ELEVENTY_PRODUCTION ? 'https://ref-beta.sebin-nyshkim.net' : 'http://localhost:8080';
|
const BASE = env.ELEVENTY_PRODUCTION
|
||||||
|
? 'https://ref-beta.sebin-nyshkim.net'
|
||||||
|
: 'http://localhost:8080';
|
||||||
|
|
||||||
// source: https://notes.jays.net/blog/11ty/
|
// source: https://notes.jays.net/blog/11ty/
|
||||||
async function getImage(type, src, key) {
|
async function getImage(type, src, key) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue