ublo-lib 1.7.10 → 1.8.0
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.
|
@@ -1,18 +1,50 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import Script from "next/script";
|
|
3
|
+
import getConfig from "next/config";
|
|
4
|
+
import { useRouter } from "next/router";
|
|
2
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
const {
|
|
7
|
+
publicRuntimeConfig
|
|
8
|
+
} = getConfig();
|
|
9
|
+
const {
|
|
10
|
+
disableClientRouting
|
|
11
|
+
} = publicRuntimeConfig;
|
|
3
12
|
const DEFAULT_SOURCE = "https://plausible.io/js/script.file-downloads.outbound-links.js";
|
|
4
|
-
const
|
|
13
|
+
const PlausibleScript = ({
|
|
5
14
|
lang,
|
|
6
15
|
plausibleDomain,
|
|
7
16
|
source = DEFAULT_SOURCE
|
|
8
17
|
}) => {
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
18
|
+
const [loaded, setLoaded] = React.useState(false);
|
|
19
|
+
const router = useRouter();
|
|
20
|
+
const hasI18n = typeof plausibleDomain === "object";
|
|
21
|
+
if (hasI18n && !lang) {
|
|
22
|
+
console.warn("PlausibleScript: the lang props is mandatory if you want to use a specific domain for each lang");
|
|
23
|
+
}
|
|
24
|
+
const domain = hasI18n ? plausibleDomain[lang] : plausibleDomain;
|
|
25
|
+
const sendPageView = React.useCallback(() => {
|
|
26
|
+
window.plausible("pageview", {
|
|
27
|
+
url: window.location.href,
|
|
28
|
+
domain,
|
|
29
|
+
screen_width: window.innerWidth
|
|
30
|
+
});
|
|
31
|
+
}, [domain]);
|
|
32
|
+
React.useEffect(() => {
|
|
33
|
+
if (!disableClientRouting && domain && loaded) {
|
|
34
|
+
router.events.on("routeChangeComplete", sendPageView);
|
|
35
|
+
return () => {
|
|
36
|
+
router.events.off("routeChangeComplete", sendPageView);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}, [domain, loaded, sendPageView]);
|
|
40
|
+
if (!domain) {
|
|
41
|
+
console.warn("PlausibleScript: domain is missing or undefined");
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return _jsx(Script, {
|
|
14
45
|
"data-domain": domain,
|
|
15
|
-
src: source
|
|
46
|
+
src: source,
|
|
47
|
+
onLoad: () => setLoaded(true)
|
|
16
48
|
});
|
|
17
49
|
};
|
|
18
|
-
export default
|
|
50
|
+
export default PlausibleScript;
|
|
@@ -30,8 +30,6 @@ const LEVELS = {
|
|
|
30
30
|
"2-snowboard": "SNOEN2",
|
|
31
31
|
"3-snowboard": "SNOEN3",
|
|
32
32
|
"snowboard-expert": "SNOEXP",
|
|
33
|
-
"ptit-freestyler": "FREE",
|
|
34
|
-
"freestyler-inter": "FREE",
|
|
35
33
|
freestyler: "FREE",
|
|
36
34
|
"freestyler-expert": "FREEXP",
|
|
37
35
|
"freestyler-pro": "FREPRO",
|
|
@@ -89,7 +87,7 @@ const Level = ({
|
|
|
89
87
|
const clicked = name => e => {
|
|
90
88
|
if (levelRef.current) {
|
|
91
89
|
levelRef.current.scrollIntoView({
|
|
92
|
-
|
|
90
|
+
behavior: "smooth",
|
|
93
91
|
block: "center",
|
|
94
92
|
inline: "center"
|
|
95
93
|
});
|