@techninja/clearstack 0.3.35 → 0.3.37

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.
Files changed (2) hide show
  1. package/lib/build-og.js +13 -5
  2. package/package.json +1 -1
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++;
@@ -133,9 +136,14 @@ function resolveMeta(config, data, baseUrl, path) {
133
136
  * @param {import('./og-template.js').OGMeta} meta
134
137
  */
135
138
  function writePage(outDir, routePath, shell, meta) {
136
- const filePath = routePath.endsWith('/')
137
- ? resolve(outDir, routePath.slice(1), 'index.html')
138
- : resolve(outDir, routePath.slice(1), 'index.html');
139
+ let filePath;
140
+ if (routePath === '/') {
141
+ filePath = resolve(outDir, 'index.html');
142
+ } else {
143
+ // Write as flat file (e.g. /dna-sources → dna-sources.html)
144
+ // Cloudflare Pages serves dna-sources.html for /dna-sources without redirect
145
+ filePath = resolve(outDir, routePath.slice(1) + '.html');
146
+ }
139
147
  mkdirSync(dirname(filePath), { recursive: true });
140
148
  writeFileSync(filePath, injectMeta(shell, meta));
141
149
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@techninja/clearstack",
3
- "version": "0.3.35",
3
+ "version": "0.3.37",
4
4
  "type": "module",
5
5
  "description": "A no-build web component framework specification — scaffold, validate, and evolve spec-compliant projects",
6
6
  "bin": {