@weaverse/hydrogen 5.13.1 → 5.14.0
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.mts +45 -3
- package/dist/index.d.ts +45 -3
- package/dist/index.js +69 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -143,6 +143,73 @@ function useWeaverseDataContext() {
|
|
|
143
143
|
function createWeaverseDataContext(matches) {
|
|
144
144
|
return createFlatDataContext(matches);
|
|
145
145
|
}
|
|
146
|
+
|
|
147
|
+
// src/seo.ts
|
|
148
|
+
function formatMetaDescriptors(seo) {
|
|
149
|
+
if (!seo) {
|
|
150
|
+
return [{ name: "robots", content: "index,follow" }];
|
|
151
|
+
}
|
|
152
|
+
let descriptors = [];
|
|
153
|
+
if (seo.title) {
|
|
154
|
+
descriptors.push({ title: seo.title });
|
|
155
|
+
}
|
|
156
|
+
if (seo.description) {
|
|
157
|
+
descriptors.push({ name: "description", content: seo.description });
|
|
158
|
+
}
|
|
159
|
+
if (seo.keywords) {
|
|
160
|
+
descriptors.push({ name: "keywords", content: seo.keywords });
|
|
161
|
+
}
|
|
162
|
+
if (seo.canonicalUrl) {
|
|
163
|
+
descriptors.push({
|
|
164
|
+
tagName: "link",
|
|
165
|
+
rel: "canonical",
|
|
166
|
+
href: seo.canonicalUrl
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
let og = seo.openGraph;
|
|
170
|
+
if (og && (og.title || og.description || og.image || og.type)) {
|
|
171
|
+
if (og.title) {
|
|
172
|
+
descriptors.push({ property: "og:title", content: og.title });
|
|
173
|
+
}
|
|
174
|
+
if (og.description) {
|
|
175
|
+
descriptors.push({ property: "og:description", content: og.description });
|
|
176
|
+
}
|
|
177
|
+
if (og.image) {
|
|
178
|
+
descriptors.push({ property: "og:image", content: og.image });
|
|
179
|
+
}
|
|
180
|
+
descriptors.push({ property: "og:type", content: og.type || "website" });
|
|
181
|
+
}
|
|
182
|
+
let tw = seo.twitter;
|
|
183
|
+
if (tw && (tw.title || tw.description || tw.image || tw.cardType)) {
|
|
184
|
+
descriptors.push({
|
|
185
|
+
name: "twitter:card",
|
|
186
|
+
content: tw.cardType || "summary"
|
|
187
|
+
});
|
|
188
|
+
if (tw.title) {
|
|
189
|
+
descriptors.push({ name: "twitter:title", content: tw.title });
|
|
190
|
+
}
|
|
191
|
+
if (tw.description) {
|
|
192
|
+
descriptors.push({ name: "twitter:description", content: tw.description });
|
|
193
|
+
}
|
|
194
|
+
if (tw.image) {
|
|
195
|
+
descriptors.push({ name: "twitter:image", content: tw.image });
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
let index = seo.robots?.index !== false;
|
|
199
|
+
let follow = seo.robots?.follow !== false;
|
|
200
|
+
descriptors.push({
|
|
201
|
+
name: "robots",
|
|
202
|
+
content: `${index ? "index" : "noindex"},${follow ? "follow" : "nofollow"}`
|
|
203
|
+
});
|
|
204
|
+
return descriptors;
|
|
205
|
+
}
|
|
206
|
+
function getWeaverseSeoMeta(data) {
|
|
207
|
+
if (!data) {
|
|
208
|
+
return formatMetaDescriptors(null);
|
|
209
|
+
}
|
|
210
|
+
let page = "items" in data && "id" in data ? data : data.page ?? null;
|
|
211
|
+
return formatMetaDescriptors(page?.seo ?? null);
|
|
212
|
+
}
|
|
146
213
|
function isProjectIdFunction(projectId) {
|
|
147
214
|
return typeof projectId === "function";
|
|
148
215
|
}
|
|
@@ -1701,6 +1768,6 @@ var IMAGES_PLACEHOLDERS = {
|
|
|
1701
1768
|
product_18: "https://cdn.shopify.com/s/files/1/0838/0052/3057/files/fpo-product-watch-2-1024x1024.svg"
|
|
1702
1769
|
};
|
|
1703
1770
|
|
|
1704
|
-
export { IMAGES_PLACEHOLDERS, ThemeTextProvider, ThemeTextStore, WeaverseClient, WeaverseError, WeaverseHydrogen, WeaverseHydrogenItem, WeaverseHydrogenRoot, createWeaverseDataContext, defaultComponents, generateDataFromSchema, getNestedKey, getPreviewData, getRequestQueries, getSelectedProductOptions, getWeaverseConfigs, hasError, hasWeaverseStudio, interpolate, isFetchProjectPayload, isProjectIdFunction, isThemeSettingsResponse, isValidHydrogenSchema, isWithCacheFetchResponse, registerComponent, useThemeSettings, useThemeText, useWeaverseDataContext, withWeaverse };
|
|
1771
|
+
export { IMAGES_PLACEHOLDERS, ThemeTextProvider, ThemeTextStore, WeaverseClient, WeaverseError, WeaverseHydrogen, WeaverseHydrogenItem, WeaverseHydrogenRoot, createWeaverseDataContext, defaultComponents, formatMetaDescriptors, generateDataFromSchema, getNestedKey, getPreviewData, getRequestQueries, getSelectedProductOptions, getWeaverseConfigs, getWeaverseSeoMeta, hasError, hasWeaverseStudio, interpolate, isFetchProjectPayload, isProjectIdFunction, isThemeSettingsResponse, isValidHydrogenSchema, isWithCacheFetchResponse, registerComponent, useThemeSettings, useThemeText, useWeaverseDataContext, withWeaverse };
|
|
1705
1772
|
//# sourceMappingURL=index.mjs.map
|
|
1706
1773
|
//# sourceMappingURL=index.mjs.map
|