@ampless/runtime 1.0.0-beta.61 → 1.0.0-beta.62
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/dist/index.d.ts +21 -0
- package/dist/index.js +11 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -336,6 +336,20 @@ interface PluginHeadApi {
|
|
|
336
336
|
* `pluginSettings.loadAll()`.
|
|
337
337
|
*/
|
|
338
338
|
contextForPlugins(): Promise<(plugin: AmplessPlugin) => PluginPublicRenderContext>;
|
|
339
|
+
/**
|
|
340
|
+
* Non-gated variant of `renderHead()` for use by the admin post preview.
|
|
341
|
+
*
|
|
342
|
+
* WHY this bypasses `isPublicRequest()`: the preview iframe is editor-only
|
|
343
|
+
* and must faithfully show what the published article looks like — including
|
|
344
|
+
* content-decoration plugins like mermaid/highlight that only register their
|
|
345
|
+
* scripts via `publicHead`. The `isPublicRequest()` gate correctly blocks
|
|
346
|
+
* analytics on public pages served to the admin or login routes, but for the
|
|
347
|
+
* preview we intentionally collect ALL publicHead descriptors so diagrams and
|
|
348
|
+
* syntax highlighting render. Analytics scripts (GA4/GTM/Plausible) also fire
|
|
349
|
+
* on preview as a side-effect; this is accepted (preview is not end-user
|
|
350
|
+
* traffic). Do NOT use this from public layouts — use `renderHead()` there.
|
|
351
|
+
*/
|
|
352
|
+
renderHeadForPreview(): Promise<ReactNode>;
|
|
339
353
|
}
|
|
340
354
|
/**
|
|
341
355
|
* Position-bucketed result of `renderHtmlForPost`. Themes embed these
|
|
@@ -576,6 +590,13 @@ interface Ampless {
|
|
|
576
590
|
postMetadata(post: Post): Promise<Metadata>;
|
|
577
591
|
siteMetadata(): Promise<Metadata>;
|
|
578
592
|
publicHead(): Promise<ReactNode>;
|
|
593
|
+
/**
|
|
594
|
+
* Non-gated head collector for the admin post preview. Collects ALL
|
|
595
|
+
* `publicHead` descriptors without calling `isPublicRequest()` so
|
|
596
|
+
* content-decoration plugins (mermaid, highlight) render in preview.
|
|
597
|
+
* Do NOT call from public layouts — use `publicHead()` there.
|
|
598
|
+
*/
|
|
599
|
+
publicHeadForPreview(): Promise<ReactNode>;
|
|
579
600
|
publicBodyEnd(): Promise<ReactNode>;
|
|
580
601
|
/**
|
|
581
602
|
* Per-post body descriptors (Phase 4 `schema` capability). Theme
|
package/dist/index.js
CHANGED
|
@@ -1589,6 +1589,16 @@ function createPluginHead(cmsConfig, pluginSettings) {
|
|
|
1589
1589
|
async contextForPlugins() {
|
|
1590
1590
|
const snapshot = await pluginSettings.loadAll();
|
|
1591
1591
|
return (plugin) => makeCtx(plugin, cmsConfig.site, snapshot);
|
|
1592
|
+
},
|
|
1593
|
+
async renderHeadForPreview() {
|
|
1594
|
+
const snapshot = await pluginSettings.loadAll();
|
|
1595
|
+
return collectFor(
|
|
1596
|
+
validPlugins,
|
|
1597
|
+
cmsConfig.site,
|
|
1598
|
+
snapshot,
|
|
1599
|
+
(p) => p.publicHead,
|
|
1600
|
+
renderHeadDescriptor
|
|
1601
|
+
);
|
|
1592
1602
|
}
|
|
1593
1603
|
};
|
|
1594
1604
|
}
|
|
@@ -1829,6 +1839,7 @@ function createAmpless(opts) {
|
|
|
1829
1839
|
postMetadata: (post) => seo.postMetadata(post),
|
|
1830
1840
|
siteMetadata: () => seo.siteMetadata(),
|
|
1831
1841
|
publicHead: () => pluginHead.renderHead(),
|
|
1842
|
+
publicHeadForPreview: () => pluginHead.renderHeadForPreview(),
|
|
1832
1843
|
publicBodyEnd: () => pluginHead.renderBodyEnd(),
|
|
1833
1844
|
publicBodyForPost: (post) => pluginHead.renderBodyForPost(post),
|
|
1834
1845
|
publicHtmlForPost: (post) => pluginHead.renderHtmlForPost(post),
|
package/package.json
CHANGED