@graphcommerce/docs 6.2.0-canary.91 → 6.2.0-canary.93

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 6.2.0-canary.93
4
+
5
+ ## 6.2.0-canary.92
6
+
3
7
  ## 6.2.0-canary.91
4
8
 
5
9
  ## 6.2.0-canary.90
Binary file
@@ -0,0 +1,107 @@
1
+ # Hygraph Dynamic Rows
2
+
3
+ Dynamic Rows offer the ability to add rows to multiple pages using rule based
4
+ relations (instead of adding a row to each page manually). These rules are based
5
+ on common properties between those pages. An example of such property would be
6
+ the category. Let's take a deeper look.
7
+
8
+ > Note
9
+ >
10
+ > The Dynamic Row functionality is available since Graphcommerce 6.2.
11
+
12
+ ## Example of injecting a Dynamic Row
13
+
14
+ Let's say we want to inject a Dynamic Row which displays a discount banner for
15
+ all socks with animal prints with a price lower than €7.50. We want to place it
16
+ after the product specs:
17
+
18
+ 1. We name the Dynamic Row `discount-banner-row`
19
+ 2. The row we want to inject. In this case the row `discount-banner`.
20
+ ![Row to insert](row-to-insert.png)
21
+ 3. We set the placement on `AFTER`
22
+ 4. The placement target will be `product-specs`
23
+ 5. For the conditions we will use the `Text` and `Number` components nested in
24
+ an `AND` component.
25
+
26
+ The result is as follows:
27
+
28
+ ![Dynamic row fields](dynamic-row-fields.png)
29
+
30
+ The Dynamic Row should now be injected on all the pages whose properties match
31
+ the conditions.
32
+
33
+ ## How does it work?
34
+
35
+ The magic of the Dynamic Row functionality, is all in the `HygrahPageContent()`
36
+ function. This function takes 4 arguments.
37
+
38
+ 1. The graphql client
39
+ 2. The current page URL
40
+ 3. Optional: The properties to match the dynamic row with. This should be an
41
+ object.
42
+ 4. Optional: Cached (standard false)
43
+
44
+ ## The structure of a Dynamic Row
45
+
46
+ To inject a dynamic row, go to Hygraph and add a Dynamic Row entry. You will see
47
+ the following fields:
48
+
49
+ 1. Internal name. This is the name of the Dynamic Row.
50
+ 2. Row. This is the Row you want to inject. i.e. a Row Column One or a Row
51
+ Links.
52
+ 3. Placement. You can place the injection before or after the placement target.
53
+ You can also replace the placement target.
54
+ 4. Placement Target. The row you want to place the Dynamic row before, after or
55
+ replaced.
56
+ 5. Conditions. Here you will match which pages should display the dynamic row.
57
+
58
+ ### Placement
59
+
60
+ Placement has a few key behaviours.
61
+
62
+ 1. When placement target is empty or not found, and before is selected, the
63
+ Dynamic Row will be placed before all other rows.
64
+ 2. When placement target is empty or not found, and after or replace is
65
+ selected, the Dynamic Row will be placed after all other rows.
66
+ 3. When placement target is found, the injected row will be placed before, after
67
+ or replace the placement target accordingly.
68
+
69
+ ### Conditions
70
+
71
+ The conditions are matched against the properties of the pages you want to
72
+ inject into. As explained in 'How does it work?' we can give an object of
73
+ properties to a page. You can add a custom object to the `HygraphPageContent()`
74
+ in your own NextJS pages. You can then use the conditions field in Hygraph to
75
+ match those properties.
76
+
77
+ The conditions field works as follows:
78
+
79
+ - We can match against string or number values using the Text and Number
80
+ components.
81
+ - Text and Number components contain a property and a value field. This way we
82
+ can match values against the page properties. If there is a match the Dynamic
83
+ Row will be injected.
84
+ - The property can be accessed with javascript dot notation. If the object
85
+ contains an array of objects, you don't have to use bracket notation. Let's
86
+ say categories is an array of category objects which hold the category name:
87
+
88
+ ```tsx
89
+ {
90
+ categories [
91
+ {
92
+ name: "Animals",
93
+ },
94
+ {
95
+ name: "Landscapes",
96
+ },
97
+ ]
98
+ }
99
+ ```
100
+
101
+ In this case, the property field can be accessed using `categories.name`
102
+ syntax.
103
+
104
+ - Number components contain an additional field called operator. Here we can
105
+ match if a number is equal to, greater than or lower than.
106
+ - We can implement logic with the And & Or components. These components allow
107
+ nesting of Text and Number components.
Binary file
package/package.json CHANGED
@@ -2,10 +2,10 @@
2
2
  "name": "@graphcommerce/docs",
3
3
  "homepage": "https://www.graphcommerce.org/docs",
4
4
  "repository": "github:graphcommerce-org/graphcommerce/docs",
5
- "version": "6.2.0-canary.91",
5
+ "version": "6.2.0-canary.93",
6
6
  "sideEffects": true,
7
7
  "devDependencies": {
8
- "@graphcommerce/prettier-config-pwa": "6.2.0-canary.91"
8
+ "@graphcommerce/prettier-config-pwa": "6.2.0-canary.93"
9
9
  },
10
10
  "prettier": "@graphcommerce/prettier-config-pwa"
11
11
  }