@techninja/clearstack 0.3.34 → 0.3.36

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/build-og.js CHANGED
@@ -22,6 +22,7 @@ import { injectMeta, interpolate } from './og-template.js';
22
22
  * @property {string} [outDir] - Output directory (default: "dist")
23
23
  * @property {string} [baseUrl] - Site base URL for og:url
24
24
  * @property {string} [htmlPath] - Path to index.html shell
25
+ * @property {Record<string, unknown>} [context] - Extra data for interpolation
25
26
  */
26
27
 
27
28
  /**
@@ -82,11 +83,13 @@ export function buildOG(opts) {
82
83
  const out = resolve(projectDir, outDir);
83
84
  let pages = 0;
84
85
 
86
+ const ctx = opts.context || {};
87
+
85
88
  for (const [pattern, config] of Object.entries(routes)) {
86
89
  const isDynamic = pattern.includes(':');
87
90
 
88
91
  if (!isDynamic) {
89
- const data = { app: { name: baseUrl } };
92
+ const data = { app: { name: baseUrl }, ...ctx };
90
93
  const meta = resolveMeta(config, data, baseUrl, pattern);
91
94
  writePage(out, pattern, shell, meta);
92
95
  pages++;
@@ -97,7 +100,7 @@ export function buildOG(opts) {
97
100
  const slug = item.slug || item.id || item[paramName];
98
101
  if (!slug) continue;
99
102
  const path = pattern.replace(`:${paramName}`, String(slug));
100
- const data = { [paramName]: item, item, app: { name: baseUrl } };
103
+ const data = { [paramName]: item, item, app: { name: baseUrl }, ...ctx };
101
104
  const meta = resolveMeta(config, data, baseUrl, path);
102
105
  writePage(out, path, shell, meta);
103
106
  pages++;
@@ -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 adds meta).
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
- const withMeta = html.replace(/<title>[^<]*<\/title>/, tags);
53
- return withMeta;
56
+ cleaned = cleaned.replace(/<title>[^<]*<\/title>/, tags);
57
+ return cleaned;
54
58
  }
55
59
 
56
60
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@techninja/clearstack",
3
- "version": "0.3.34",
3
+ "version": "0.3.36",
4
4
  "type": "module",
5
5
  "description": "A no-build web component framework specification — scaffold, validate, and evolve spec-compliant projects",
6
6
  "bin": {