@unhead/ssr 0.2.5 → 0.2.6

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/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # @unhead/dom
2
+
3
+ ## Install
4
+
5
+ ```bash
6
+ # yarn add @unhead/dom
7
+ npm install @unhead/ssr
8
+ ```
9
+
10
+ ## Documentation
11
+
12
+ See the [unhead](https://unhead.harlanzw.com/) for more details.
package/dist/index.cjs CHANGED
@@ -39,14 +39,23 @@ function ssrRenderTags(tags) {
39
39
  };
40
40
  }
41
41
 
42
- async function renderSSRHead(ctx) {
43
- const tags = await ctx.resolveTags();
44
- const beforeRenderCtx = { tags };
45
- await ctx.hooks.callHook("ssr:beforeRender", beforeRenderCtx);
42
+ async function renderSSRHead(head) {
43
+ const tags = await head.resolveTags();
44
+ const beforeRenderCtx = { shouldRender: true, tags };
45
+ if (!beforeRenderCtx.shouldRender) {
46
+ return {
47
+ headTags: "",
48
+ bodyTags: "",
49
+ bodyTagsOpen: "",
50
+ htmlAttrs: "",
51
+ bodyAttrs: ""
52
+ };
53
+ }
54
+ await head.hooks.callHook("ssr:beforeRender", beforeRenderCtx);
46
55
  const html = ssrRenderTags(beforeRenderCtx.tags);
47
- const renderCXx = { tags, html };
48
- await ctx.hooks.callHook("ssr:render", renderCXx);
49
- return renderCXx.html;
56
+ const renderCtx = { tags, html };
57
+ await head.hooks.callHook("ssr:render", renderCtx);
58
+ return renderCtx.html;
50
59
  }
51
60
 
52
61
  exports.renderSSRHead = renderSSRHead;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { HeadClient, SSRHeadPayload } from '@unhead/schema';
1
+ import { Unhead, SSRHeadPayload } from '@unhead/schema';
2
2
 
3
- declare function renderSSRHead<T extends {}>(ctx: HeadClient<T>): Promise<SSRHeadPayload>;
3
+ declare function renderSSRHead<T extends {}>(head: Unhead<T>): Promise<SSRHeadPayload>;
4
4
 
5
5
  export { renderSSRHead };
package/dist/index.mjs CHANGED
@@ -37,14 +37,23 @@ function ssrRenderTags(tags) {
37
37
  };
38
38
  }
39
39
 
40
- async function renderSSRHead(ctx) {
41
- const tags = await ctx.resolveTags();
42
- const beforeRenderCtx = { tags };
43
- await ctx.hooks.callHook("ssr:beforeRender", beforeRenderCtx);
40
+ async function renderSSRHead(head) {
41
+ const tags = await head.resolveTags();
42
+ const beforeRenderCtx = { shouldRender: true, tags };
43
+ if (!beforeRenderCtx.shouldRender) {
44
+ return {
45
+ headTags: "",
46
+ bodyTags: "",
47
+ bodyTagsOpen: "",
48
+ htmlAttrs: "",
49
+ bodyAttrs: ""
50
+ };
51
+ }
52
+ await head.hooks.callHook("ssr:beforeRender", beforeRenderCtx);
44
53
  const html = ssrRenderTags(beforeRenderCtx.tags);
45
- const renderCXx = { tags, html };
46
- await ctx.hooks.callHook("ssr:render", renderCXx);
47
- return renderCXx.html;
54
+ const renderCtx = { tags, html };
55
+ await head.hooks.callHook("ssr:render", renderCtx);
56
+ return renderCtx.html;
48
57
  }
49
58
 
50
59
  export { renderSSRHead };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unhead/ssr",
3
3
  "type": "module",
4
- "version": "0.2.5",
4
+ "version": "0.2.6",
5
5
  "packageManager": "pnpm@7.14.0",
6
6
  "author": "Harlan Wilton <harlan@harlanzw.com>",
7
7
  "license": "MIT",
@@ -30,7 +30,7 @@
30
30
  "dist"
31
31
  ],
32
32
  "dependencies": {
33
- "@unhead/schema": "0.2.5"
33
+ "@unhead/schema": "0.2.6"
34
34
  },
35
35
  "devDependencies": {
36
36
  "zhead": "1.0.0-beta.10"