@decocms/blocks 7.26.2 → 7.26.3
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/package.json +1 -1
- package/src/cms/schema.test.ts +4 -19
- package/src/cms/schema.ts +9 -12
package/package.json
CHANGED
package/src/cms/schema.test.ts
CHANGED
|
@@ -271,7 +271,10 @@ describe("commerce SEO section schemas", () => {
|
|
|
271
271
|
expect(props.jsonLD.hide).toBe(true);
|
|
272
272
|
});
|
|
273
273
|
|
|
274
|
-
it("
|
|
274
|
+
it("registers the defs + manifest blocks and offers them as page.seo options", () => {
|
|
275
|
+
// Unconditional (no commerce gate): meta.gen.json is baked at generation
|
|
276
|
+
// time when the loader registry is empty, and the runtime serves that baked
|
|
277
|
+
// meta as-is, so a registry-based gate would never bake the options.
|
|
275
278
|
const meta = composeMeta(emptySiteMeta());
|
|
276
279
|
for (const key of [
|
|
277
280
|
"commerce/sections/Seo/SeoPLPV2.tsx",
|
|
@@ -279,24 +282,6 @@ describe("commerce SEO section schemas", () => {
|
|
|
279
282
|
]) {
|
|
280
283
|
expect(meta.manifest.blocks.sections).toHaveProperty(key);
|
|
281
284
|
expect(meta.schema.definitions).toHaveProperty(b64(key));
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
it("offers them as page.seo options only on a commerce site", () => {
|
|
286
|
-
// "commerce site" = product-list loaders registered (the signal
|
|
287
|
-
// buildFrameworkSections gates the picker on). The key must match
|
|
288
|
-
// inferLoaderTags so it is tagged "product-list".
|
|
289
|
-
registerAppSchemas({
|
|
290
|
-
namespace: "vtex",
|
|
291
|
-
loaders: {
|
|
292
|
-
"vtex/loaders/test/ProductListForSeoPicker.ts": { type: "object", properties: {} },
|
|
293
|
-
},
|
|
294
|
-
});
|
|
295
|
-
const meta = composeMeta(emptySiteMeta());
|
|
296
|
-
for (const key of [
|
|
297
|
-
"commerce/sections/Seo/SeoPLPV2.tsx",
|
|
298
|
-
"commerce/sections/Seo/SeoPDPV2.tsx",
|
|
299
|
-
]) {
|
|
300
285
|
expect(meta.schema.root.sections.anyOf).toContainEqual(b64Ref(key));
|
|
301
286
|
}
|
|
302
287
|
});
|
package/src/cms/schema.ts
CHANGED
|
@@ -736,12 +736,6 @@ function buildFrameworkSections(sectionAnyOf: any[]) {
|
|
|
736
736
|
const manifestBlocks: Record<string, any> = {};
|
|
737
737
|
const extraAnyOf: any[] = [];
|
|
738
738
|
|
|
739
|
-
// A site is "commerce" when it registered product-list loaders (same signal
|
|
740
|
-
// wrapResolvableProperties uses). Gates whether the commerce SEO section types
|
|
741
|
-
// below are offered as pickable page.seo options — a blog site should not see
|
|
742
|
-
// "Product listing SEO" in the SEO type dropdown.
|
|
743
|
-
const hasCommerce = getProductListLoaderKeys().length > 0;
|
|
744
|
-
|
|
745
739
|
// --- website/sections/Rendering/Lazy.tsx ---
|
|
746
740
|
const LAZY_TYPE = "website/sections/Rendering/Lazy.tsx";
|
|
747
741
|
const lazyKey = toBase64(LAZY_TYPE);
|
|
@@ -848,10 +842,13 @@ function buildFrameworkSections(sectionAnyOf: any[]) {
|
|
|
848
842
|
// data-source block-ref set once when the page is created; it round-trips via
|
|
849
843
|
// the form (kept `hide`) rather than being re-picked in the SEO panel.
|
|
850
844
|
//
|
|
851
|
-
//
|
|
852
|
-
//
|
|
853
|
-
//
|
|
854
|
-
//
|
|
845
|
+
// Added to `extraAnyOf` (offered as a selectable page.seo type) unconditionally,
|
|
846
|
+
// like the website Seo sections above. Gating this on "is a commerce site" via
|
|
847
|
+
// the loader registry does NOT work: meta.gen.json is baked at generation time
|
|
848
|
+
// (blocks-cli), when the registry is empty, and the runtime serves that baked,
|
|
849
|
+
// already-composed meta as-is (composeMeta is idempotent on it) — so a gate
|
|
850
|
+
// would drop the options at bake and never re-add them. Non-commerce sites
|
|
851
|
+
// seeing these two extra options is a minor, acceptable cost.
|
|
855
852
|
const SEO_PLP_V2_TYPE = "commerce/sections/Seo/SeoPLPV2.tsx";
|
|
856
853
|
const seoPlpV2Key = toBase64(SEO_PLP_V2_TYPE);
|
|
857
854
|
definitions[seoPlpV2Key] = {
|
|
@@ -887,7 +884,7 @@ function buildFrameworkSections(sectionAnyOf: any[]) {
|
|
|
887
884
|
$ref: `#/definitions/${seoPlpV2Key}`,
|
|
888
885
|
namespace: "commerce",
|
|
889
886
|
};
|
|
890
|
-
|
|
887
|
+
extraAnyOf.push({ $ref: `#/definitions/${seoPlpV2Key}` });
|
|
891
888
|
|
|
892
889
|
// --- commerce/sections/Seo/SeoPDPV2.tsx ---
|
|
893
890
|
// Product-details SEO. Studio "pdp" mode counterpart of the PLP section above.
|
|
@@ -920,7 +917,7 @@ function buildFrameworkSections(sectionAnyOf: any[]) {
|
|
|
920
917
|
$ref: `#/definitions/${seoPdpV2Key}`,
|
|
921
918
|
namespace: "commerce",
|
|
922
919
|
};
|
|
923
|
-
|
|
920
|
+
extraAnyOf.push({ $ref: `#/definitions/${seoPdpV2Key}` });
|
|
924
921
|
|
|
925
922
|
// --- website/flags/multivariate/section.ts ---
|
|
926
923
|
const MV_SECTION_TYPE = "website/flags/multivariate/section.ts";
|