qumra-engine 2.0.83 → 2.0.84
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.
|
@@ -13,41 +13,46 @@ exports.default = new (class SeoExtension {
|
|
|
13
13
|
}
|
|
14
14
|
run({ env, ctx }) {
|
|
15
15
|
const injectionCode = (0, globals_1.getGlobal)("injectionCode");
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
let isIframe = false;
|
|
17
|
+
if (env.getGlobal("isIframe")) {
|
|
18
|
+
isIframe = env.getGlobal("isIframe");
|
|
19
|
+
}
|
|
20
20
|
let scripts = `
|
|
21
21
|
${injectionCode.body}
|
|
22
22
|
`;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
23
|
+
if (isIframe) {
|
|
24
|
+
scripts += `
|
|
25
|
+
<script>
|
|
26
|
+
function attachIframeLinkListeners(root = document) {
|
|
27
|
+
const links = root.querySelectorAll("a");
|
|
28
|
+
links.forEach(link => {
|
|
29
|
+
if (link.dataset._iframeHandled) return;
|
|
30
|
+
link.dataset._iframeHandled = "true";
|
|
31
|
+
|
|
32
|
+
link.addEventListener("click", function (e) {
|
|
33
|
+
const href = link.getAttribute("href");
|
|
34
|
+
if (!href || href === "#") return;
|
|
35
|
+
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
e.stopPropagation();
|
|
38
|
+
|
|
39
|
+
window.parent.postMessage(
|
|
40
|
+
{ type: "iframeLinkClick", href },
|
|
41
|
+
"*"
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
document.addEventListener("DOMContentLoaded", function () {
|
|
48
|
+
attachIframeLinkListeners();
|
|
49
|
+
|
|
50
|
+
const observer = new MutationObserver(() => attachIframeLinkListeners());
|
|
51
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
52
|
+
});
|
|
53
|
+
</script>
|
|
54
|
+
`;
|
|
55
|
+
}
|
|
51
56
|
return new nunjucks_1.runtime.SafeString(scripts);
|
|
52
57
|
}
|
|
53
58
|
})();
|
|
@@ -15,6 +15,9 @@ const mergeDataMiddleware = async (req, res, next) => {
|
|
|
15
15
|
if (res.locals.isIframe) {
|
|
16
16
|
res.locals.env.addGlobal("isIframe", res.locals.isIframe);
|
|
17
17
|
}
|
|
18
|
+
else {
|
|
19
|
+
res.locals.env.addGlobal("isIframe", false);
|
|
20
|
+
}
|
|
18
21
|
res.locals.env.addGlobal("templates", res.locals.render.engine?.templates);
|
|
19
22
|
res.locals.env.addGlobal("engineData", res.locals.render.engine);
|
|
20
23
|
res.locals.env.addGlobal("widgets", widgets);
|
package/dist/middleware.js
CHANGED
|
@@ -33,7 +33,6 @@ const startEngine = async ({ renderApi, mode, getRender, setRender, port = 3000,
|
|
|
33
33
|
return;
|
|
34
34
|
});
|
|
35
35
|
app.use((req, res, next) => {
|
|
36
|
-
res.locals.isIframe = false;
|
|
37
36
|
const isIframe = req.query.iframe === "1" || req.headers["sec-fetch-dest"] === "iframe";
|
|
38
37
|
if (isIframe) {
|
|
39
38
|
console.log("🚀 هذا الطلب جاي من iframe");
|