@unhead/ssr 1.3.9 → 1.4.1
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.cjs +7 -8
- package/dist/index.d.cts +20 -0
- package/dist/index.d.mts +20 -0
- package/dist/index.mjs +7 -8
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -2,17 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
const shared = require('@unhead/shared');
|
|
4
4
|
|
|
5
|
+
function encodeAttribute(value) {
|
|
6
|
+
return String(value).replace(/"/g, """);
|
|
7
|
+
}
|
|
5
8
|
function propsToString(props) {
|
|
6
|
-
const
|
|
9
|
+
const attrs = [];
|
|
7
10
|
for (const [key, value] of Object.entries(props)) {
|
|
8
|
-
if (value
|
|
9
|
-
|
|
10
|
-
let attribute = key;
|
|
11
|
-
if (value !== true)
|
|
12
|
-
attribute += `="${String(value).replace(/"/g, """)}"`;
|
|
13
|
-
handledAttributes.push(attribute);
|
|
11
|
+
if (value !== false && value !== null)
|
|
12
|
+
attrs.push(value === true ? key : `${key}="${encodeAttribute(value)}"`);
|
|
14
13
|
}
|
|
15
|
-
return
|
|
14
|
+
return `${attrs.length > 0 ? " " : ""}${attrs.join(" ")}`;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
function escapeHtml(str) {
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Unhead, SSRHeadPayload, HeadTag } from '@unhead/schema';
|
|
2
|
+
export { SSRHeadPayload } from '@unhead/schema';
|
|
3
|
+
|
|
4
|
+
declare function renderSSRHead<T extends {}>(head: Unhead<T>): Promise<SSRHeadPayload>;
|
|
5
|
+
|
|
6
|
+
declare function propsToString(props: Record<string, any>): string;
|
|
7
|
+
|
|
8
|
+
declare function escapeHtml(str: string): string;
|
|
9
|
+
declare function escapeJson(str: string): string;
|
|
10
|
+
declare function tagToString<T extends HeadTag>(tag: T): string;
|
|
11
|
+
|
|
12
|
+
declare function ssrRenderTags<T extends HeadTag>(tags: T[]): {
|
|
13
|
+
headTags: string;
|
|
14
|
+
bodyTags: string;
|
|
15
|
+
bodyTagsOpen: string;
|
|
16
|
+
htmlAttrs: string;
|
|
17
|
+
bodyAttrs: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { escapeHtml, escapeJson, propsToString, renderSSRHead, ssrRenderTags, tagToString };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Unhead, SSRHeadPayload, HeadTag } from '@unhead/schema';
|
|
2
|
+
export { SSRHeadPayload } from '@unhead/schema';
|
|
3
|
+
|
|
4
|
+
declare function renderSSRHead<T extends {}>(head: Unhead<T>): Promise<SSRHeadPayload>;
|
|
5
|
+
|
|
6
|
+
declare function propsToString(props: Record<string, any>): string;
|
|
7
|
+
|
|
8
|
+
declare function escapeHtml(str: string): string;
|
|
9
|
+
declare function escapeJson(str: string): string;
|
|
10
|
+
declare function tagToString<T extends HeadTag>(tag: T): string;
|
|
11
|
+
|
|
12
|
+
declare function ssrRenderTags<T extends HeadTag>(tags: T[]): {
|
|
13
|
+
headTags: string;
|
|
14
|
+
bodyTags: string;
|
|
15
|
+
bodyTagsOpen: string;
|
|
16
|
+
htmlAttrs: string;
|
|
17
|
+
bodyAttrs: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { escapeHtml, escapeJson, propsToString, renderSSRHead, ssrRenderTags, tagToString };
|
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { TagsWithInnerContent, SelfClosingTags } from '@unhead/shared';
|
|
2
2
|
|
|
3
|
+
function encodeAttribute(value) {
|
|
4
|
+
return String(value).replace(/"/g, """);
|
|
5
|
+
}
|
|
3
6
|
function propsToString(props) {
|
|
4
|
-
const
|
|
7
|
+
const attrs = [];
|
|
5
8
|
for (const [key, value] of Object.entries(props)) {
|
|
6
|
-
if (value
|
|
7
|
-
|
|
8
|
-
let attribute = key;
|
|
9
|
-
if (value !== true)
|
|
10
|
-
attribute += `="${String(value).replace(/"/g, """)}"`;
|
|
11
|
-
handledAttributes.push(attribute);
|
|
9
|
+
if (value !== false && value !== null)
|
|
10
|
+
attrs.push(value === true ? key : `${key}="${encodeAttribute(value)}"`);
|
|
12
11
|
}
|
|
13
|
-
return
|
|
12
|
+
return `${attrs.length > 0 ? " " : ""}${attrs.join(" ")}`;
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
function escapeHtml(str) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unhead/ssr",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.4.1",
|
|
5
5
|
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://github.com/sponsors/harlan-zw",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@unhead/schema": "1.
|
|
33
|
-
"@unhead/shared": "1.
|
|
32
|
+
"@unhead/schema": "1.4.1",
|
|
33
|
+
"@unhead/shared": "1.4.1"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "unbuild .",
|