@techninja/clearstack 0.3.34 → 0.3.35
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/lib/og-template.js +7 -3
- package/package.json +1 -1
package/lib/og-template.js
CHANGED
|
@@ -41,16 +41,20 @@ export function buildMetaTags(meta) {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
* Inject OG meta tags into an HTML shell (replaces <title> and
|
|
44
|
+
* Inject OG meta tags into an HTML shell (replaces <title> and existing OG/twitter meta).
|
|
45
45
|
* @param {string} html - The base index.html content
|
|
46
46
|
* @param {OGMeta} meta
|
|
47
47
|
* @returns {string}
|
|
48
48
|
*/
|
|
49
49
|
export function injectMeta(html, meta) {
|
|
50
50
|
const tags = buildMetaTags(meta);
|
|
51
|
+
// Strip existing OG and twitter meta tags (single or multi-line)
|
|
52
|
+
let cleaned = html.replace(/\s*<meta\s+(?:property="og:[^"]*"|name="twitter:[^"]*")[^>]*\/?>/g, '');
|
|
53
|
+
// Also strip standalone name="description" meta
|
|
54
|
+
cleaned = cleaned.replace(/\s*<meta\s+name="description"[^>]*\/?>/g, '');
|
|
51
55
|
// Replace existing <title>...</title> with full meta block
|
|
52
|
-
|
|
53
|
-
return
|
|
56
|
+
cleaned = cleaned.replace(/<title>[^<]*<\/title>/, tags);
|
|
57
|
+
return cleaned;
|
|
54
58
|
}
|
|
55
59
|
|
|
56
60
|
/**
|
package/package.json
CHANGED