astro-accelerator 0.0.59 → 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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.
|
|
2
|
+
"version": "0.0.61",
|
|
3
3
|
"author": "Steve Fenton",
|
|
4
4
|
"name": "astro-accelerator",
|
|
5
5
|
"description": "A super-lightweight, accessible, SEO-friendly starter project for Astro",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@squoosh/lib": "^0.4.0",
|
|
28
28
|
"astro": "^1.8.0",
|
|
29
|
-
"astro-accelerator-utils": "^0.2.
|
|
29
|
+
"astro-accelerator-utils": "^0.2.17",
|
|
30
30
|
"hast-util-from-selector": "^2.0.0",
|
|
31
31
|
"remark-directive": "^2.0.1"
|
|
32
32
|
},
|
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
|
};
|
|
@@ -20,7 +20,7 @@ const _ = Lang(lang);
|
|
|
20
20
|
const accelerator = new Accelerator(SITE);
|
|
21
21
|
|
|
22
22
|
const currentUrl = new URL(Astro.request.url);
|
|
23
|
-
const navPages = accelerator.navigation.breadcrumbs(currentUrl, SITE.subfolder);
|
|
23
|
+
const navPages = accelerator.navigation.breadcrumbs(currentUrl, SITE.subfolder, breadcrumbs?.length ?? 0);
|
|
24
24
|
let metaIndex = navPages.length;
|
|
25
25
|
---
|
|
26
26
|
<nav class="site-breadcrumbs" aria-label={ _(Translations.aria.breadcrumbs) }>
|
|
@@ -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
|
|