@obelism/content 0.19.2 → 0.21.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.
@@ -2,6 +2,8 @@ const UID_ATTRIBUTE = 'data-cms-uid';
2
2
  const ENTRY_ATTRIBUTE = 'data-cms-entry';
3
3
  const PRODUCT_ATTRIBUTE = 'data-cms-product';
4
4
  const PRODUCT_HANDLE_ATTRIBUTE = 'data-cms-product-handle';
5
+ const COLLECTION_ATTRIBUTE = 'data-cms-collection';
6
+ const COLLECTION_HANDLE_ATTRIBUTE = 'data-cms-collection-handle';
5
7
  // The attribute that lets editors select a block on the page, in the visual
6
8
  // editor and on the site. Spread it on the block's outermost element:
7
9
  //
@@ -36,6 +38,18 @@ const editableProduct = (product)=>product?.id ? {
36
38
  'data-cms-product': product.id,
37
39
  'data-cms-product-handle': product.handle
38
40
  } : {};
41
+ // The Shopify collection a page shows, on a collection route: editing on the
42
+ // site then offers "Add a collection page" when the page has no collection
43
+ // page yet (no `editable(entry)`), and makes one for this collection.
44
+ //
45
+ // <main {...editableCollection(collection)} {...editable(page)}>…</main>
46
+ //
47
+ // `collection` is the store's (its GID and handle), from the Storefront API
48
+ // or a Shopify field.
49
+ const editableCollection = (collection)=>collection?.id ? {
50
+ 'data-cms-collection': collection.id,
51
+ 'data-cms-collection-handle': collection.handle
52
+ } : {};
39
53
 
40
54
  // The visual editor loads the site in an iframe at the environment's preview
41
55
  // URL plus the entry's path, with these parameters added. `cms_token` is a
@@ -84,11 +98,14 @@ const readPreviewParams = (input)=>{
84
98
  };
85
99
  };
86
100
 
101
+ exports.COLLECTION_ATTRIBUTE = COLLECTION_ATTRIBUTE;
102
+ exports.COLLECTION_HANDLE_ATTRIBUTE = COLLECTION_HANDLE_ATTRIBUTE;
87
103
  exports.ENTRY_ATTRIBUTE = ENTRY_ATTRIBUTE;
88
104
  exports.PREVIEW_PARAMS = PREVIEW_PARAMS;
89
105
  exports.PRODUCT_ATTRIBUTE = PRODUCT_ATTRIBUTE;
90
106
  exports.PRODUCT_HANDLE_ATTRIBUTE = PRODUCT_HANDLE_ATTRIBUTE;
91
107
  exports.UID_ATTRIBUTE = UID_ATTRIBUTE;
92
108
  exports.editable = editable;
109
+ exports.editableCollection = editableCollection;
93
110
  exports.editableProduct = editableProduct;
94
111
  exports.readPreviewParams = readPreviewParams;
package/dist/site.js CHANGED
@@ -94,11 +94,16 @@ const PROXY_ROUTES = [
94
94
  method: 'POST',
95
95
  pattern: /^entries$/
96
96
  },
97
- // "Add a product page" on a product the site marks (editableProduct).
97
+ // "Add a product page" on a product the site marks (editableProduct),
98
+ // "Add a collection page" on a collection (editableCollection).
98
99
  {
99
100
  method: 'POST',
100
101
  pattern: /^product-pages$/
101
102
  },
103
+ {
104
+ method: 'POST',
105
+ pattern: /^collection-pages$/
106
+ },
102
107
  // The one-time address of the CMS's entry form (the prompt box's Form).
103
108
  {
104
109
  method: 'POST',
package/dist/site.mjs CHANGED
@@ -92,11 +92,16 @@ const PROXY_ROUTES = [
92
92
  method: 'POST',
93
93
  pattern: /^entries$/
94
94
  },
95
- // "Add a product page" on a product the site marks (editableProduct).
95
+ // "Add a product page" on a product the site marks (editableProduct),
96
+ // "Add a collection page" on a collection (editableCollection).
96
97
  {
97
98
  method: 'POST',
98
99
  pattern: /^product-pages$/
99
100
  },
101
+ {
102
+ method: 'POST',
103
+ pattern: /^collection-pages$/
104
+ },
100
105
  // The one-time address of the CMS's entry form (the prompt box's Form).
101
106
  {
102
107
  method: 'POST',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@obelism/content",
3
3
  "description": "Obelism Content SDK: the delivery API client, the visual editor bridge with prompt editing, editing on your own site, webhook verification, and the content model CLI",
4
- "version": "0.19.2",
4
+ "version": "0.21.0",
5
5
  "keywords": [
6
6
  "cms",
7
7
  "headless-cms",