@seip/blue-bird 0.2.0 → 0.2.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/core/template.js +21 -6
- package/package.json +1 -1
package/core/template.js
CHANGED
|
@@ -78,6 +78,12 @@ class Template {
|
|
|
78
78
|
* @returns {string} The HTML string of the React component.
|
|
79
79
|
* @example
|
|
80
80
|
* const options = {
|
|
81
|
+
* langHtml: "en",
|
|
82
|
+
* metaTags: {
|
|
83
|
+
* titleMeta: "Page Title",
|
|
84
|
+
* descriptionMeta: "Page description",
|
|
85
|
+
* keywordsMeta: "keyword1, keyword2",
|
|
86
|
+
* },
|
|
81
87
|
* head: [
|
|
82
88
|
* { tag: "meta", attrs: { name: "description", content: "Description" } },
|
|
83
89
|
* { tag: "link", attrs: { rel: "stylesheet", href: "style.css" } }
|
|
@@ -98,24 +104,33 @@ class Template {
|
|
|
98
104
|
const classBody = options.classBody || "";
|
|
99
105
|
const linkStyles = options.linkStyles || [];
|
|
100
106
|
const scriptScripts = options.scriptScripts || [];
|
|
107
|
+
const langHtml = options.langHtml || props.langMeta || "en";
|
|
108
|
+
const metaTags = {
|
|
109
|
+
titleMeta: options.metaTags?.titleMeta || props.titleMeta,
|
|
110
|
+
descriptionMeta: options.metaTags?.descriptionMeta || props.descriptionMeta,
|
|
111
|
+
keywordsMeta: options.metaTags?.keywordsMeta || props.keywordsMeta,
|
|
112
|
+
authorMeta: options.metaTags?.authorMeta || props.authorMeta,
|
|
113
|
+
langMeta: options.metaTags?.langMeta || props.langMeta,
|
|
114
|
+
};
|
|
115
|
+
|
|
101
116
|
const html = `
|
|
102
117
|
<!DOCTYPE html>
|
|
103
|
-
<html lang="${this.escapeHtml(
|
|
118
|
+
<html lang="${this.escapeHtml(langHtml)}">
|
|
104
119
|
<head>
|
|
105
120
|
<meta charset="UTF-8">
|
|
106
121
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
107
|
-
<title>${this.escapeHtml(
|
|
122
|
+
<title>${this.escapeHtml(metaTags.titleMeta)}</title>
|
|
108
123
|
<link rel="icon" href="favicon.ico" />
|
|
109
|
-
<meta name="description" content="${this.escapeHtml(
|
|
110
|
-
<meta name="keywords" content="${this.escapeHtml(
|
|
111
|
-
<meta name="author" content="${this.escapeHtml(
|
|
124
|
+
<meta name="description" content="${this.escapeHtml(metaTags.descriptionMeta)}"/>
|
|
125
|
+
<meta name="keywords" content="${this.escapeHtml(metaTags.keywordsMeta)}"/>
|
|
126
|
+
<meta name="author" content="${this.escapeHtml(metaTags.authorMeta)}"/>
|
|
112
127
|
${linkStyles.map(item => `<link rel="stylesheet" href="${item.href}" />`).join("")}
|
|
113
|
-
${scriptScripts.map(item => `<script src="${item.src}"></script>`).join("")}
|
|
114
128
|
${optionsHead.map(item => `<${item.tag} ${Object.entries(item.attrs).map(([key, value]) => `${key}="${value}"`).join(" ")} />`).join("")}
|
|
115
129
|
</head>
|
|
116
130
|
<body class="${classBody}">
|
|
117
131
|
${this.react(component, propsReact)}
|
|
118
132
|
${this.vite_assets()}
|
|
133
|
+
${scriptScripts.map(item => `<script src="${item.src}"></script>`).join("")}
|
|
119
134
|
</body>
|
|
120
135
|
</html>
|
|
121
136
|
`
|