qumra-engine 2.0.52 → 2.0.54

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.
@@ -11,11 +11,13 @@ exports.default = new (class SeoExtension {
11
11
  return new nodes.CallExtension(this, "run", null);
12
12
  }
13
13
  run({ ctx }) {
14
- const escapeHtml = (str) => String(str || "")
15
- .replace(/&/g, "&")
16
- .replace(/</g, "&lt;")
17
- .replace(/>/g, "&gt;")
18
- .replace(/"/g, "&quot;");
14
+ // const escapeHtml = (str: string) =>
15
+ // String(str || "")
16
+ // .replace(/&/g, "&amp;")
17
+ // .replace(/</g, "&lt;")
18
+ // .replace(/>/g, "&gt;")
19
+ // .replace(/"/g, "&quot;");
20
+ const getTextOnly = (str) => String(str || "").replace(/<[^>]*>/g, "");
19
21
  const seo = ctx.context.seo || {};
20
22
  const page = ctx.context.page || {};
21
23
  const store = ctx.context.store || {};
@@ -23,18 +25,30 @@ exports.default = new (class SeoExtension {
23
25
  const pageTitle = seo.title || page.title || "Store";
24
26
  const pageDescription = seo.description || page.description || "";
25
27
  const pageImage = seo.image || "";
26
- const favicon = pageImage || "/favicon.ico"; // الأولوية للوجو
28
+ const favicon = seo.logo || "/favicon.ico"; // الأولوية للوجو
27
29
  let tags = `
28
- <title>${escapeHtml(pageTitle)}</title>
29
- ${favicon ? `<link rel="icon" type="image/png" href="${escapeHtml(favicon)}">` : ""}
30
- ${pageDescription ? `<meta name="description" content="${escapeHtml(pageDescription)}">` : ""}
31
- ${pageUrl ? `<link rel="canonical" href="${escapeHtml(pageUrl)}">` : ""}
32
- <meta property="og:title" content="${escapeHtml(pageTitle)}">
33
- ${pageDescription ? `<meta property="og:description" content="${escapeHtml(pageDescription)}">` : ""}
34
- ${pageImage ? `<meta property="og:image" content="${escapeHtml(pageImage)}">` : ""}
35
- ${pageUrl ? `<meta property="og:url" content="${escapeHtml(pageUrl)}">` : ""}
30
+ <title>${getTextOnly(pageTitle)}</title>
31
+ ${favicon
32
+ ? `<link rel="icon" type="image/png" href="${getTextOnly(favicon)}">`
33
+ : ""}
34
+ ${pageDescription
35
+ ? `<meta name="description" content="${getTextOnly(pageDescription)}">`
36
+ : ""}
37
+ ${pageUrl ? `<link rel="canonical" href="${getTextOnly(pageUrl)}">` : ""}
38
+ <meta property="og:title" content="${getTextOnly(pageTitle)}">
39
+ ${pageDescription
40
+ ? `<meta property="og:description" content="${getTextOnly(pageDescription)}">`
41
+ : ""}
42
+ ${pageImage
43
+ ? `<meta property="og:image" content="${getTextOnly(pageImage)}">`
44
+ : ""}
45
+ ${pageUrl
46
+ ? `<meta property="og:url" content="${getTextOnly(pageUrl)}">`
47
+ : ""}
36
48
  <meta property="og:type" content="website">
37
- ${pageImage ? `<meta name="twitter:card" content="summary_large_image">` : `<meta name="twitter:card" content="summary">`}
49
+ ${pageImage
50
+ ? `<meta name="twitter:card" content="summary_large_image">`
51
+ : `<meta name="twitter:card" content="summary">`}
38
52
  `;
39
53
  return new nunjucks_1.runtime.SafeString(tags.trim());
40
54
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qumra-engine",
3
- "version": "2.0.52",
3
+ "version": "2.0.54",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {