hubspot-cms-sync 0.5.1 → 0.5.3
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/package.json +1 -1
- package/src/adapters/theme.mjs +6 -1
- package/src/lib/render.mjs +6 -3
- package/src/republish.mjs +9 -2
package/package.json
CHANGED
package/src/adapters/theme.mjs
CHANGED
|
@@ -95,7 +95,12 @@ const REF_BEARING = (relPath) => {
|
|
|
95
95
|
return (
|
|
96
96
|
p === 'js/hs-forms.js' ||
|
|
97
97
|
p.endsWith('.module/fields.json') ||
|
|
98
|
-
p.endsWith('.module/module.html')
|
|
98
|
+
p.endsWith('.module/module.html') ||
|
|
99
|
+
// Page templates (incl. shared partials) may carry @asset refs to content
|
|
100
|
+
// assets (e.g. og:image, founder/product photos). Resolve them to the
|
|
101
|
+
// target's hosted URL on push, same as module.html — keeps content images
|
|
102
|
+
// (webp included, which the theme source rejects) out of the theme tree.
|
|
103
|
+
(p.startsWith('templates/') && p.endsWith('.html'))
|
|
99
104
|
);
|
|
100
105
|
};
|
|
101
106
|
|
package/src/lib/render.mjs
CHANGED
|
@@ -261,7 +261,10 @@ export function renderPost(post, { siteDir, site, baseUrl = '', assetBase = '/as
|
|
|
261
261
|
nav_active: null,
|
|
262
262
|
nav_hide_cta: false,
|
|
263
263
|
};
|
|
264
|
-
|
|
264
|
+
// Resolve @asset refs that live in the TEMPLATE itself (not just content fields) —
|
|
265
|
+
// e.g. og:image or img src pointing at content assets. Idempotent: already-resolved
|
|
266
|
+
// content has no @asset tokens left.
|
|
267
|
+
return resolveStaticRefs(env.render(template, context), { assetBase });
|
|
265
268
|
}
|
|
266
269
|
|
|
267
270
|
// ---------------------------------------------------------------------------
|
|
@@ -292,7 +295,7 @@ export function renderPage(page, { siteDir, site, baseUrl = '', assetBase = '/as
|
|
|
292
295
|
nav_active: null,
|
|
293
296
|
nav_hide_cta: false,
|
|
294
297
|
};
|
|
295
|
-
return env.render(page.template, context);
|
|
298
|
+
return resolveStaticRefs(env.render(page.template, context), { assetBase });
|
|
296
299
|
}
|
|
297
300
|
|
|
298
301
|
// ---------------------------------------------------------------------------
|
|
@@ -313,7 +316,7 @@ export function renderBlogListing(posts, { siteDir, site, baseUrl = '', assetBas
|
|
|
313
316
|
nav_active: null,
|
|
314
317
|
nav_hide_cta: false,
|
|
315
318
|
};
|
|
316
|
-
return env.render('templates/blog.html', context);
|
|
319
|
+
return resolveStaticRefs(env.render('templates/blog.html', context), { assetBase });
|
|
317
320
|
}
|
|
318
321
|
|
|
319
322
|
export { postContent, pageContent, assetUrl, localizeDate, makeEnv };
|
package/src/republish.mjs
CHANGED
|
@@ -73,10 +73,17 @@ async function republish(argv = process.argv.slice(2), opts = {}) {
|
|
|
73
73
|
const fut = future();
|
|
74
74
|
let ok = 0;
|
|
75
75
|
let fail = 0;
|
|
76
|
+
let skipped = 0;
|
|
76
77
|
async function schedule(kind, id, publishDate) {
|
|
77
78
|
const body = { id: String(id), publishDate: publishDate || fut };
|
|
78
79
|
const { status } = await hub('POST', `/cms/v3/${kind}/schedule`, body);
|
|
79
|
-
|
|
80
|
+
// 409 = the page already has a scheduled publish (e.g. just published by a
|
|
81
|
+
// `push --publish`, or an orphan portal page) — the desired end state, not a
|
|
82
|
+
// failure. `--all` legitimately touches pages outside our manifest; don't let
|
|
83
|
+
// their conflicts fail the deploy. Log for visibility.
|
|
84
|
+
if (status === 204) ok++;
|
|
85
|
+
else if (status === 409) { skipped++; console.error(` ${kind} ${id} -> 409 already scheduled (skip)`); }
|
|
86
|
+
else { fail++; console.error(` ${kind} ${id} -> ${status}`); }
|
|
80
87
|
}
|
|
81
88
|
|
|
82
89
|
const pages = await getAll('/cms/v3/pages/site-pages?property=id,slug,state');
|
|
@@ -91,7 +98,7 @@ async function republish(argv = process.argv.slice(2), opts = {}) {
|
|
|
91
98
|
console.log(`republishing ${posts.length} blog post(s) (preserving publishDate)`);
|
|
92
99
|
for (const p of posts) await schedule('blogs/posts', p.id, p.publishDate);
|
|
93
100
|
}
|
|
94
|
-
console.log(`scheduled ${ok} | failed ${fail} (live in ~90s)`);
|
|
101
|
+
console.log(`scheduled ${ok} | already-scheduled ${skipped} | failed ${fail} (live in ~90s)`);
|
|
95
102
|
return fail ? 1 : 0;
|
|
96
103
|
}
|
|
97
104
|
|