hubspot-cms-sync 0.5.0 → 0.5.2
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 +12 -3
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
|
@@ -228,6 +228,12 @@ function makeEnv(siteDir, { site, opts }) {
|
|
|
228
228
|
env.addFilter('format_date', formatDate);
|
|
229
229
|
|
|
230
230
|
env.addGlobal('get_asset_url', assetUrl);
|
|
231
|
+
// Absolute site origin from the build's baseUrl (e.g. https://www2.7thsense.io).
|
|
232
|
+
// Templates need it for absolute URLs that relative paths can't satisfy —
|
|
233
|
+
// og:image/twitter:image especially, which social scrapers reject when relative.
|
|
234
|
+
// Empty string on the HubSpot target (where baseUrl is unset), so a template
|
|
235
|
+
// that does `base_url ~ '/assets/x'` yields a root-relative path there.
|
|
236
|
+
env.addGlobal('base_url', opts.baseUrl || '');
|
|
231
237
|
env.addGlobal('html_lang', opts.lang || 'en');
|
|
232
238
|
env.addGlobal('html_lang_dir', '');
|
|
233
239
|
env.addGlobal('standard_header_includes', opts.headerIncludes || '');
|
|
@@ -255,7 +261,10 @@ export function renderPost(post, { siteDir, site, baseUrl = '', assetBase = '/as
|
|
|
255
261
|
nav_active: null,
|
|
256
262
|
nav_hide_cta: false,
|
|
257
263
|
};
|
|
258
|
-
|
|
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 });
|
|
259
268
|
}
|
|
260
269
|
|
|
261
270
|
// ---------------------------------------------------------------------------
|
|
@@ -286,7 +295,7 @@ export function renderPage(page, { siteDir, site, baseUrl = '', assetBase = '/as
|
|
|
286
295
|
nav_active: null,
|
|
287
296
|
nav_hide_cta: false,
|
|
288
297
|
};
|
|
289
|
-
return env.render(page.template, context);
|
|
298
|
+
return resolveStaticRefs(env.render(page.template, context), { assetBase });
|
|
290
299
|
}
|
|
291
300
|
|
|
292
301
|
// ---------------------------------------------------------------------------
|
|
@@ -307,7 +316,7 @@ export function renderBlogListing(posts, { siteDir, site, baseUrl = '', assetBas
|
|
|
307
316
|
nav_active: null,
|
|
308
317
|
nav_hide_cta: false,
|
|
309
318
|
};
|
|
310
|
-
return env.render('templates/blog.html', context);
|
|
319
|
+
return resolveStaticRefs(env.render('templates/blog.html', context), { assetBase });
|
|
311
320
|
}
|
|
312
321
|
|
|
313
322
|
export { postContent, pageContent, assetUrl, localizeDate, makeEnv };
|