@ludo.ninja/components 2.2.32 → 2.2.33
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.
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assetMediasOpengraph = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const Urls_1 = require("../../dto/common/Media/Urls");
|
|
6
|
+
const getMediaVariant_1 = require("../media/getMediaVariant");
|
|
7
|
+
const types_1 = require("../media/types");
|
|
8
|
+
const env_1 = require("../../store/env");
|
|
9
|
+
// render as function (bug in next js for next/head)
|
|
10
|
+
// export as function, don't use as Component
|
|
11
|
+
const assetMediasOpengraph = ({ medias, alt }) => {
|
|
12
|
+
const { NEXT_PUBLIC_STATIC_DOMAIN, getAudioDomain, getVideoDomain } = (0, env_1.useEnvStore)((state) => ({
|
|
13
|
+
NEXT_PUBLIC_STATIC_DOMAIN: state.NEXT_PUBLIC_STATIC_DOMAIN,
|
|
14
|
+
getAudioDomain: state.getAudioDomain,
|
|
15
|
+
getVideoDomain: state.getVideoDomain,
|
|
16
|
+
}));
|
|
17
|
+
const media = medias[0];
|
|
18
|
+
if (!media)
|
|
19
|
+
return null;
|
|
20
|
+
const mediaVariant = (0, getMediaVariant_1.getMediaVariant)({ media });
|
|
21
|
+
switch (mediaVariant) {
|
|
22
|
+
case types_1.EMediaVariants.audio:
|
|
23
|
+
return (0, jsx_runtime_1.jsx)("meta", { property: "og:audio", content: (0, Urls_1.isExternalMediaAudio)(media.media, getAudioDomain) });
|
|
24
|
+
case types_1.EMediaVariants.video:
|
|
25
|
+
const url = (0, Urls_1.isExternalMediaVideo)(media.media, getVideoDomain);
|
|
26
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("meta", { property: "og:video", content: url }), (0, jsx_runtime_1.jsx)("meta", { property: "og:video:secure_url", content: url }), (0, jsx_runtime_1.jsx)("meta", { property: "og:video:type", content: "application/x-shockwave-flash" }), (0, jsx_runtime_1.jsx)("meta", { property: "og:image", content: url }), (0, jsx_runtime_1.jsx)("meta", { property: "\u201Dog:image:width\u201D", content: "1280" }), (0, jsx_runtime_1.jsx)("meta", { property: "\u201Dog:image:height\u201D", content: "720" })] }));
|
|
27
|
+
case types_1.EMediaVariants.object3d:
|
|
28
|
+
//todo: add preview url
|
|
29
|
+
// const previewUrl = isExternalMediaImage(media.media, mediaSizes.regular, process.env.NEXT_PUBLIC_STATIC_DOMAIN);
|
|
30
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}));
|
|
31
|
+
case types_1.EMediaVariants.image:
|
|
32
|
+
case types_1.EMediaVariants.other:
|
|
33
|
+
case types_1.EMediaVariants.screenshot:
|
|
34
|
+
default:
|
|
35
|
+
const urlDefault = (0, Urls_1.isExternalMediaImage)(media.media, Urls_1.mediaSizes.regular, NEXT_PUBLIC_STATIC_DOMAIN);
|
|
36
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("meta", { property: "og:image", content: urlDefault }), (0, jsx_runtime_1.jsx)("meta", { property: "og:image:alt", content: alt }), (0, jsx_runtime_1.jsx)("meta", { name: "twitter:image", content: urlDefault }), (0, jsx_runtime_1.jsx)("meta", { property: "twitter:image:alt", content: alt })] }));
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.assetMediasOpengraph = assetMediasOpengraph;
|
package/package.json
CHANGED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AssetMediasOpengraph = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const Urls_1 = require("../../dto/common/Media/Urls");
|
|
6
|
-
const getMediaVariant_1 = require("../media/getMediaVariant");
|
|
7
|
-
const types_1 = require("../media/types");
|
|
8
|
-
const env_1 = require("../../store/env");
|
|
9
|
-
const AssetMediasOpengraph = ({ medias, alt }) => {
|
|
10
|
-
if (!medias[0])
|
|
11
|
-
return null;
|
|
12
|
-
return [medias[0]].map((media) => {
|
|
13
|
-
const mediaVariant = (0, getMediaVariant_1.getMediaVariant)({ media });
|
|
14
|
-
switch (mediaVariant) {
|
|
15
|
-
case types_1.EMediaVariants.audio:
|
|
16
|
-
return (0, jsx_runtime_1.jsx)(AudioOpengraph, { media: media });
|
|
17
|
-
case types_1.EMediaVariants.video:
|
|
18
|
-
return (0, jsx_runtime_1.jsx)(VideoOpengraph, { media: media });
|
|
19
|
-
case types_1.EMediaVariants.object3d:
|
|
20
|
-
return (0, jsx_runtime_1.jsx)(Object3DOpengraph, { media: media, alt: alt });
|
|
21
|
-
case types_1.EMediaVariants.other:
|
|
22
|
-
case types_1.EMediaVariants.image:
|
|
23
|
-
case types_1.EMediaVariants.screenshot:
|
|
24
|
-
default:
|
|
25
|
-
return (0, jsx_runtime_1.jsx)(ImageOpengraph, { media: media, alt: alt });
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
exports.AssetMediasOpengraph = AssetMediasOpengraph;
|
|
30
|
-
const ImageOpengraph = ({ media, alt }) => {
|
|
31
|
-
const NEXT_PUBLIC_STATIC_DOMAIN = (0, env_1.useEnvStore)((state) => state.NEXT_PUBLIC_STATIC_DOMAIN);
|
|
32
|
-
const url = (0, Urls_1.isExternalMediaImage)(media.media, Urls_1.mediaSizes.regular, NEXT_PUBLIC_STATIC_DOMAIN);
|
|
33
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("meta", { property: "og:image", content: url }), (0, jsx_runtime_1.jsx)("meta", { property: "og:image:alt", content: alt }), (0, jsx_runtime_1.jsx)("meta", { name: "twitter:image", content: url }), (0, jsx_runtime_1.jsx)("meta", { property: "twitter:image:alt", content: alt })] }));
|
|
34
|
-
};
|
|
35
|
-
const AudioOpengraph = ({ media }) => {
|
|
36
|
-
const getAudioENVDomain = (0, env_1.useEnvStore)((state) => state.getAudioDomain);
|
|
37
|
-
return (0, jsx_runtime_1.jsx)("meta", { property: "og:audio", content: (0, Urls_1.isExternalMediaAudio)(media.media, getAudioENVDomain) });
|
|
38
|
-
};
|
|
39
|
-
const VideoOpengraph = ({ media }) => {
|
|
40
|
-
const getVideoDomain = (0, env_1.useEnvStore)((state) => state.getVideoDomain);
|
|
41
|
-
const url = (0, Urls_1.isExternalMediaVideo)(media.media, getVideoDomain);
|
|
42
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("meta", { property: "og:video", content: url }), (0, jsx_runtime_1.jsx)("meta", { property: "og:video:secure_url", content: url }), (0, jsx_runtime_1.jsx)("meta", { property: "og:video:type", content: "application/x-shockwave-flash" }), (0, jsx_runtime_1.jsx)("meta", { property: "og:image", content: url }), (0, jsx_runtime_1.jsx)("meta", { property: "\u201Dog:image:width\u201D", content: "1280" }), (0, jsx_runtime_1.jsx)("meta", { property: "\u201Dog:image:height\u201D", content: "720" })] }));
|
|
43
|
-
};
|
|
44
|
-
const Object3DOpengraph = ({ media, alt }) => {
|
|
45
|
-
//todo: add preview url
|
|
46
|
-
// const NEXT_PUBLIC_STATIC_DOMAIN = useEnvStore((state) => state.NEXT_PUBLIC_STATIC_DOMAIN);
|
|
47
|
-
// const previewUrl = isExternalMediaImage(media.media, mediaSizes.regular, NEXT_PUBLIC_STATIC_DOMAIN);
|
|
48
|
-
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}));
|
|
49
|
-
};
|