@unhead/ssr 0.2.5 → 0.2.7
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 +12 -0
- package/dist/index.cjs +16 -7
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +16 -7
- package/package.json +2 -2
package/README.md
ADDED
package/dist/index.cjs
CHANGED
|
@@ -39,14 +39,23 @@ function ssrRenderTags(tags) {
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
async function renderSSRHead(
|
|
43
|
-
const tags = await
|
|
44
|
-
const beforeRenderCtx = { tags };
|
|
45
|
-
|
|
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
|
|
48
|
-
await
|
|
49
|
-
return
|
|
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 {
|
|
1
|
+
import { Unhead, SSRHeadPayload } from '@unhead/schema';
|
|
2
2
|
|
|
3
|
-
declare function renderSSRHead<T extends {}>(
|
|
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(
|
|
41
|
-
const tags = await
|
|
42
|
-
const beforeRenderCtx = { tags };
|
|
43
|
-
|
|
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
|
|
46
|
-
await
|
|
47
|
-
return
|
|
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.
|
|
4
|
+
"version": "0.2.7",
|
|
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.
|
|
33
|
+
"@unhead/schema": "0.2.7"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"zhead": "1.0.0-beta.10"
|