astro-accelerator 0.0.60 → 0.0.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -36,8 +36,9 @@ const SITE: Site = {
|
|
|
36
36
|
youTubeLinks: ['embed'],
|
|
37
37
|
},
|
|
38
38
|
images: {
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
// Generated using https://ausi.github.io/respimagelint/
|
|
40
|
+
contentSize: '(min-width: 1280px) 668px, (min-width: 880px) calc(72.11vw - 241px), calc(100vw - 64px)',
|
|
41
|
+
listerSize: '(min-width: 1300px) 350px, (min-width: 880px) calc(34.25vw - 88px), (min-width: 700px) 50vw, calc(100vw - 32px)',
|
|
41
42
|
authorSize: '50px',
|
|
42
43
|
}
|
|
43
44
|
};
|
|
@@ -51,27 +51,41 @@ export function getImageInfo(src, className, sizes) {
|
|
|
51
51
|
const imgMedium = getDestination(uri, size.medium);
|
|
52
52
|
const imgLarge = getDestination(uri, size.large);
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
info.srcset = `${imgSmall} ${size.small}w, ${imgMedium} ${size.medium}w, ${imgLarge}`;
|
|
56
|
-
info.sizes = sizes;
|
|
57
|
-
info.class = (className ?? '' + ' resp-img').trim();
|
|
54
|
+
let nativeSize = size.large;
|
|
58
55
|
info.metadata = null;
|
|
59
56
|
|
|
60
|
-
if ([imgSmall, imgMedium, imgLarge].includes(src)) {
|
|
61
|
-
info.srcset = null;
|
|
62
|
-
info.sizes = null;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
57
|
try {
|
|
66
58
|
let metaAddress = path.join(workingDirectory, 'public', src + '.json');
|
|
67
|
-
|
|
59
|
+
|
|
68
60
|
if (fs.existsSync(metaAddress)) {
|
|
69
61
|
info.metadata = JSON.parse(fs.readFileSync(metaAddress));
|
|
62
|
+
nativeSize = info.metadata.width;
|
|
70
63
|
}
|
|
71
64
|
} catch (e) {
|
|
72
65
|
console.warn(e);
|
|
73
66
|
}
|
|
74
67
|
|
|
68
|
+
info.src = imgFallback;
|
|
69
|
+
// use info.metadata to limit the {}w size to the image size if it's smaller
|
|
70
|
+
let srcset = `${imgSmall} ${Math.min(size.small, nativeSize)}w`;
|
|
71
|
+
|
|
72
|
+
if (nativeSize >= size.small) {
|
|
73
|
+
srcset += `, ${imgMedium} ${Math.min(size.medium, nativeSize)}w`;
|
|
74
|
+
|
|
75
|
+
if (nativeSize >= size.medium) {
|
|
76
|
+
srcset += `, ${imgLarge} ${Math.min(size.large, nativeSize)}w`;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
info.srcset = srcset;
|
|
81
|
+
info.sizes = sizes;
|
|
82
|
+
info.class = (className ?? '' + ' resp-img').trim();
|
|
83
|
+
|
|
84
|
+
if ([imgSmall, imgMedium, imgLarge].includes(src)) {
|
|
85
|
+
info.srcset = null;
|
|
86
|
+
info.sizes = null;
|
|
87
|
+
}
|
|
88
|
+
|
|
75
89
|
return info;
|
|
76
90
|
}
|
|
77
91
|
|