All files / apps/portfolio/app/utils workScreenshot.ts

100% Statements 9/9
90% Branches 9/10
100% Functions 2/2
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 328x           8x           8x             8x     14x 14x   14x       8x 5x  
const SOURCES = import.meta.glob<string>("../assets/work/*.jpg", {
    eager: true,
    import: "default",
    query: { w: "1440", format: "webp" },
});
 
const SRCSETS = import.meta.glob<string>("../assets/work/*.jpg", {
    eager: true,
    import: "default",
    query: { w: "480;960;1440", format: "webp", as: "srcset" },
});
 
const SHARES = import.meta.glob<string>("../assets/work/*.jpg", {
    eager: true,
    import: "default",
    query: { w: "1200", h: "630", fit: "cover", position: "top", format: "jpg" },
});
 
/** A case study's screenshot as WebP at three widths, for an `<img>` to bind with `v-bind`. */
export const workScreenshot = (work: {
    screenshot?: { file: string };
}): { src: string; srcset: string } | undefined => {
    const key = work.screenshot && `../assets/work/${work.screenshot.file}`;
    const src = key && SOURCES[key];
 
    return src ? { src, srcset: SRCSETS[key] ?? src } : undefined;
};
 
/** A case study's screenshot cropped from the top to 1200×630, the size share cards render. */
export const workShareImage = (work: { screenshot?: { file: string } }): string | undefined =>
    work.screenshot && SHARES[`../assets/work/${work.screenshot.file}`];