astro-accelerator 6.1.2 → 6.1.3
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/public/css/main.css
CHANGED
|
@@ -1078,10 +1078,19 @@ figure:focus .magnify-button {
|
|
|
1078
1078
|
@media (prefers-reduced-motion: no-preference) {
|
|
1079
1079
|
|
|
1080
1080
|
.magnify-icon,
|
|
1081
|
-
.copy-button
|
|
1082
|
-
|
|
1083
|
-
|
|
1081
|
+
.copy-button {
|
|
1082
|
+
transition: all 0.2s ease-in;
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
.anim-show-parent .list-item img {
|
|
1084
1086
|
transition: all 0.2s ease-in;
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
|
|
1090
|
+
.anim-show-parent .list-item {
|
|
1091
|
+
transition-duration: 0.2s;
|
|
1092
|
+
transition-timing-function: ease-in;
|
|
1093
|
+
transition-property: transform, filter, box-shadow, background-color, color, opacity;
|
|
1085
1094
|
scale: calc(0.75 + (var(--shown, 1) * 0.25));
|
|
1086
1095
|
}
|
|
1087
1096
|
}
|
|
@@ -12,8 +12,7 @@ import { qsa } from './query.js';
|
|
|
12
12
|
/**
|
|
13
13
|
* Assists animation by setting "--shown" CSS property
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
* Otherwise it will be --shown: 0
|
|
15
|
+
* As an item enters/exits the viewport, --shown moves from 0..1
|
|
17
16
|
* This allows CSS transitions and calculated properties to animate elements
|
|
18
17
|
*
|
|
19
18
|
* Example
|
|
@@ -25,15 +24,16 @@ import { qsa } from './query.js';
|
|
|
25
24
|
function addIntersectionObserver(listItemQuery) {
|
|
26
25
|
function handleIntersection(entries, observer) {
|
|
27
26
|
for (let entry of entries) {
|
|
28
|
-
const value = entry.isIntersecting ?
|
|
27
|
+
const value = entry.isIntersecting ? entry.intersectionRatio : 0;
|
|
29
28
|
entry.target.style.setProperty('--shown', value);
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
|
|
32
|
+
const thresholds = Array.from({ length: 21 }, (_, i) => i / 20);
|
|
33
33
|
const options = {
|
|
34
34
|
root: null,
|
|
35
35
|
rootMargin: '0px',
|
|
36
|
-
threshold:
|
|
36
|
+
threshold: thresholds,
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
const observer = new IntersectionObserver(handleIntersection, options);
|
|
@@ -44,8 +44,7 @@ function addIntersectionObserver(listItemQuery) {
|
|
|
44
44
|
/**
|
|
45
45
|
* Assists animation by setting "--shown" CSS property
|
|
46
46
|
*
|
|
47
|
-
*
|
|
48
|
-
* Otherwise it will be --shown: 0
|
|
47
|
+
* As an item enters/exits the viewport, --img-shown moves from 0..1
|
|
49
48
|
* This allows CSS transitions and calculated properties to animate elements
|
|
50
49
|
*
|
|
51
50
|
* Example
|
|
@@ -57,15 +56,16 @@ function addIntersectionObserver(listItemQuery) {
|
|
|
57
56
|
function addListImageIntersectionObserver(imgItemQuery) {
|
|
58
57
|
function handleIntersection(entries, observer) {
|
|
59
58
|
for (let entry of entries) {
|
|
60
|
-
const value = entry.isIntersecting ?
|
|
59
|
+
const value = entry.isIntersecting ? entry.intersectionRatio : 0;
|
|
61
60
|
entry.target.style.setProperty('--img-shown', value);
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
63
|
|
|
64
|
+
const thresholds = Array.from({ length: 21 }, (_, i) => i / 20);
|
|
65
65
|
const options = {
|
|
66
66
|
root: null,
|
|
67
67
|
rootMargin: '0px',
|
|
68
|
-
threshold:
|
|
68
|
+
threshold: thresholds,
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
const observer = new IntersectionObserver(handleIntersection, options);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
// warning: This file is overwritten by Astro Accelerator
|
|
3
|
+
|
|
4
|
+
import { PostOrdering, PostFiltering, Accelerator } from 'astro-accelerator-utils';
|
|
5
|
+
import { SITE } from '@config';
|
|
6
|
+
import ArticleList from '@components/ArticleList.astro';
|
|
7
|
+
|
|
8
|
+
const accelerator = new Accelerator(SITE);
|
|
9
|
+
const stats = new accelerator.statistics('accelerator/components/RecentlyPublished.astro');
|
|
10
|
+
stats.start();
|
|
11
|
+
|
|
12
|
+
// Properties
|
|
13
|
+
type Props = {
|
|
14
|
+
lang?: string;
|
|
15
|
+
count: number;
|
|
16
|
+
path?: string;
|
|
17
|
+
};
|
|
18
|
+
const { lang = SITE.default.lang, count, path } = Astro.props satisfies Props;
|
|
19
|
+
|
|
20
|
+
// Logic
|
|
21
|
+
const allPages = accelerator.posts.all();
|
|
22
|
+
const normalizedPath = path
|
|
23
|
+
? `/${path.replace(/^\/+/, '').replace(/\/+$/, '')}`
|
|
24
|
+
: null;
|
|
25
|
+
const pages = allPages
|
|
26
|
+
.filter(PostFiltering.hasDate)
|
|
27
|
+
.filter(PostFiltering.isListable)
|
|
28
|
+
.filter((post) => {
|
|
29
|
+
if (!normalizedPath) return true;
|
|
30
|
+
const postUrl = post.url || '';
|
|
31
|
+
return postUrl === normalizedPath || postUrl.startsWith(`${normalizedPath}/`);
|
|
32
|
+
})
|
|
33
|
+
.sort(PostOrdering.sortByPubDateDesc)
|
|
34
|
+
.slice(0, count);
|
|
35
|
+
|
|
36
|
+
stats.stop();
|
|
37
|
+
---
|
|
38
|
+
<ArticleList lang={lang} posts={pages} />
|