strapi-plugin-navigation 3.0.0-beta.6 → 3.0.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/README.md CHANGED
@@ -2,24 +2,22 @@
2
2
  <img style="width: 150px; height: auto;" src="public/assets/logo.png" alt="Logo - Strapi Navigation plugin" />
3
3
  </div>
4
4
  <div align="center">
5
- <h1>Strapi v5 - Navigation plugin - Beta</h1>
5
+ <h1>Strapi - Navigation plugin</h1>
6
6
  <p>Create consumable navigation with a simple and straightforward visual builder</p>
7
7
  <a href="https://www.npmjs.org/package/strapi-plugin-navigation">
8
- <img alt="GitHub package.json version" src="https://img.shields.io/github/package-json/v/VirtusLab-Open-Source/strapi-plugin-navigation/v5?label=npm&logo=npm">
8
+ <img alt="GitHub package.json version" src="https://img.shields.io/github/package-json/v/VirtusLab-Open-Source/strapi-plugin-navigation?label=npm&logo=npm">
9
9
  </a>
10
10
  <a href="https://www.npmjs.org/package/strapi-plugin-navigation">
11
11
  <img src="https://img.shields.io/npm/dm/strapi-plugin-navigation.svg" alt="Monthly download on NPM" />
12
12
  </a>
13
13
  <a href="https://circleci.com/gh/VirtusLab/strapi-plugin-navigation">
14
- <img src="https://circleci.com/gh/VirtusLab-Open-Source/strapi-plugin-navigation/tree/v5.svg?style=shield" alt="CircleCI" />
14
+ <img src="https://circleci.com/gh/VirtusLab-Open-Source/strapi-plugin-navigation.svg?style=shield" alt="CircleCI" />
15
15
  </a>
16
16
  <a href="https://codecov.io/gh/VirtusLab/strapi-plugin-navigation">
17
- <img src="https://codecov.io/gh/VirtusLab/strapi-plugin-navigation/coverage.svg?branch=v5" alt="codecov.io" />
17
+ <img src="https://codecov.io/gh/VirtusLab/strapi-plugin-navigation/coverage.svg?branch=master" alt="codecov.io" />
18
18
  </a>
19
19
  </div>
20
20
 
21
- ## ⚠️ This is the beta version for Strapi v5
22
-
23
21
  ---
24
22
 
25
23
  <div style="margin: 20px 0" align="center">
@@ -39,15 +37,15 @@ Strapi Navigation Plugin provides a website navigation / menu builder feature fo
39
37
  3. [⏳ Installation](#-installation)
40
38
  4. [🖐 Requirements](#-requirements)
41
39
  5. [🔧 Basic Configuration](#-configuration)
42
- - [Settings page](#in-v203-and-newer)
43
- - [Plugin file](#in-v202-and-older--default-configuration-state-for-v203-and-newer)
40
+ - [Settings page](#in-v203-and-newer)
41
+ - [Plugin file](#in-v202-and-older--default-configuration-state-for-v203-and-newer)
44
42
  6. [🔧 GraphQL Configuration](#-gql-configuration)
45
- 7. [🌍 i18n Internationalization](#-i18n-internationalization)
43
+ 7. [🌍 i18n](#-i18n)
46
44
  8. [👤 RBAC](#-rbac)
47
45
  9. [🔐 Authorization strategy](#-authorization-strategy)
48
46
  10. [🕸️ Public API specification](#%EF%B8%8F-public-api-specification)
49
- - [REST API](#rest-api)
50
- - [GraphQL API](#graphql-api)
47
+ - [REST API](#rest-api)
48
+ - [GraphQL API](#graphql-api)
51
49
  11. [🔌 Extensions](#-extensions)
52
50
  12. [🌿 Model lifecycle hooks](#model-life-cycle-hooks)
53
51
  13. [🧹 REST Cache](#rest-cache)
@@ -57,8 +55,8 @@ Strapi Navigation Plugin provides a website navigation / menu builder feature fo
57
55
  17. [👨‍💻 Community support](#-community-support)
58
56
 
59
57
  ## 💎 Versions
60
- - **Strapi v5** - (current) [v3.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-navigation/tree/v5)
61
- - **Strapi v4** - [v2.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-navigation)
58
+ - **Strapi v5** - (current) [v3.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-navigation)
59
+ - **Strapi v4** - [v2.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-navigation/tree/strapi-v4)
62
60
  - **Strapi v3** - [v1.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-navigation/tree/strapi-v3)
63
61
 
64
62
  ## ✨ Features
@@ -71,12 +69,6 @@ Strapi Navigation Plugin provides a website navigation / menu builder feature fo
71
69
  - **Light / Dark mode compatible:** By design we're supporting Strapi ☀️ Light / 🌙 Dark modes
72
70
  - **Webhooks integration:** Changes to navigation will trigger 'entry.update' or 'entry.create' webhook events.
73
71
  - **Customizable:** Possibility to customize the options like: available Content Types, Maximum level for "attach to menu", Additional fields (audience)
74
- - **[Audit log](https://github.com/VirtusLab/strapi-molecules/tree/master/packages/strapi-plugin-audit-log):** integration with Strapi Molecules Audit Log plugin that provides changes track record
75
-
76
- ## ⚙️ Versions
77
-
78
- - **Strapi v5** - (current) - [v3.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-navigation)
79
- - **Strapi v4** - [v2.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-navigation/tree/strapi-v4)
80
72
 
81
73
  ## ⏳ Installation
82
74
 
@@ -93,7 +85,7 @@ As a ✅ **verified** plugin by Strapi team we're available on the [**Strapi Mar
93
85
  It's recommended to use **yarn** to install this plugin within your Strapi project. [You can install yarn with these docs](https://yarnpkg.com/lang/en/docs/install/).
94
86
 
95
87
  ```bash
96
- yarn add strapi-plugin-navigation@beta
88
+ yarn add strapi-plugin-navigation@latest
97
89
  ```
98
90
 
99
91
  After successful installation you've to re-build your Strapi instance. To archive that simply use:
@@ -117,11 +109,11 @@ All done. Enjoy 🎉
117
109
 
118
110
  ## 🖐 Requirements
119
111
 
120
- Complete installation requirements are exact same as for Strapi itself and can be found in the documentation under <a href="https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/installation/cli.html#preparing-the-installation">Installation Requirements</a>.
112
+ Complete installation requirements are exact same as for Strapi itself and can be found in the documentation under <a href="https://docs.strapi.io/dev-docs/installation/cli#preparing-the-installation">Installation Requirements</a>.
121
113
 
122
114
  **Supported Strapi versions**:
123
115
 
124
- - Strapi v5.4.1 (recently tested)
116
+ - Strapi v5.5.1 (recently tested)
125
117
  - Strapi v5.x
126
118
 
127
119
  > This plugin is designed for **Strapi v5** and is not working with v4.x. To get version for **Strapi v4** install version [v4.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-navigation/tree/strapi-v4).
@@ -130,7 +122,7 @@ Complete installation requirements are exact same as for Strapi itself and can b
130
122
 
131
123
  ## 🔧 Configuration
132
124
 
133
- To start your journey with **Navigation plugin** you must first setup it using the dedicated Settings page or for any version, put your configuration in `config/plugins.js`. Anyway we're recommending the click-through option where your configuration is going to be properly validated.
125
+ To start your journey with **Navigation plugin** you must first setup it using the dedicated Settings page or for any version, put your configuration in `config/plugins.{js,ts}`. Anyway we're recommending the click-through option where your configuration is going to be properly validated.
134
126
 
135
127
  ### Settings page
136
128
 
@@ -145,10 +137,10 @@ On the dedicated page, you will be able to set up all crucial properties which d
145
137
 
146
138
  ### File
147
139
 
148
- Config for this plugin is stored as a part of the `config/plugins.js` or `config/<env>/plugins.js` file. You can use the following snippet to make sure that the config structure is correct. If you've got already configurations for other plugins stores by this way, you can use the `navigation` along with them.
140
+ Config for this plugin is stored as a part of the `config/plugins.{js, ts}` or `config/<env>/plugins.{js,ts}` file. You can use the following snippet to make sure that the config structure is correct. If you've got already configurations for other plugins stores by this way, you can use the `navigation` along with them.
149
141
 
150
142
 
151
- ```js
143
+ ```ts
152
144
  module.exports = ({ env }) => ({
153
145
  // ...
154
146
  navigation: {
@@ -176,7 +168,7 @@ Config for this plugin is stored as a part of the `config/plugins.js` or `config
176
168
  - `contentTypesNameFields` - Definition of content type title fields like `'api::<collection name>.<content type name>': ['field_name_1', 'field_name_2']`, if not set titles are pulled from fields like `['title', 'subject', 'name']`. **TIP** - Proper content type uid you can find in the URL of Content Manager where you're managing relevant entities like: `admin/content-manager/collectionType/< THE UID HERE >?page=1&pageSize=10&sort=Title:ASC&plugins[i18n][locale]=en`
177
169
  - `pathDefaultFields` - The attribute to copy the default path from per content type. Syntax: `'api::<collection name>.<content type name>': ['url_slug', 'path']`
178
170
  - `gql` - If you're using GraphQL that's the right place to put all necessary settings. More **[ here ](#gql-configuration)**
179
- - `i18nEnabled` - should you want to manage multi-locale content via navigation set this value `Enabled`. More **[ here ](#i18n-internationalization)**
171
+ - `i18nEnabled` - should you want to manage multi-locale content via navigation set this value `Enabled`. More **[ here ](#i18n)**
180
172
  - `cascadeMenuAttached` - If you don't want "Menu attached" to cascade on child items set this value `Disabled`.
181
173
 
182
174
  ### Properties
@@ -187,7 +179,7 @@ It is advised to configure additional fields through the plugin's Settings Page.
187
179
  Creating configuration for additional fields with the `config.(js|ts)` file should be done with caution. Config object contains the `additionalFields` property of type `Array<CustomField | 'audience'>`, where CustomField is of type `{ type: 'string' | 'boolean' | { "name": string, "url": string, "mime": string, "width": number, "height": number, "previewUrl": string }, name: string, label: string }`. When creating custom fields be advised that the `name` property has to be unique. When editing a custom field it is advised not to edit its `name` and `type` properties. After config has been restored the custom fields that are not present in `config.js` file will be deleted and their values in navigation items will be lost.
188
180
 
189
181
  ## 🔧 GQL Configuration
190
- Using navigation with GraphQL requires both plugins to be installed and working. You can find installation guide for GraphQL plugin **[here](https://docs.strapi.io/developer-docs/latest/plugins/graphql.html#graphql)**. To properly configure GQL to work with navigation you should provide `gql` prop. This should contain union types that will be used to define GQL response format for your data while fetching:
182
+ Using navigation with GraphQL requires both plugins to be installed and working. You can find installation guide for GraphQL plugin **[here](https://docs.strapi.io/dev-docs/plugins/graphql#graphql)**. To properly configure GQL to work with navigation you should provide `gql` prop. This should contain union types that will be used to define GQL response format for your data while fetching:
191
183
 
192
184
  > **Important!**
193
185
  > If you're using `config/plugins.js` to configure your plugins , please put `navigation` property before `graphql`. Otherwise types are not going to be properly added to GraphQL Schema. That's because of dynamic types which base on plugin configuration which are added on `bootstrap` stage, not `register`. This is not valid if you're using `graphql` plugin without any custom configuration, so most of cases in real.
@@ -200,7 +192,7 @@ related: NavigationRelated
200
192
 
201
193
  This prop should look as follows:
202
194
 
203
- ```js
195
+ ```ts
204
196
  gql: {
205
197
  navigationItemRelated: ['<your GQL related content types>'],
206
198
  },
@@ -208,36 +200,16 @@ gql: {
208
200
 
209
201
  for example:
210
202
 
211
- ```js
203
+ ```ts
212
204
  gql: {
213
205
  navigationItemRelated: ['Page', 'UploadFile'],
214
206
  },
215
207
  ```
216
208
  where `Page` and `UploadFile` are your type names for the **Content Types** you're referring by navigation items relations.
217
209
 
218
- ## 🌍 i18n Internationalization
219
-
220
- On server startup missing navigations for other locales will be created. From then you can manage navigation's localizations just like before.
221
-
222
- If your newly created navigation localization is empty you can copy contents of one version's to the empty one. If related item is localized and locale version exists localization will be used as a related item. Otherwise plugin will fallback to an original item.
223
-
224
- ### Rendering
210
+ ## 🌍 i18n
225
211
 
226
- Shape of the rendered navigation will not change. Querying stays almost the same. To query for specific locale version just add `locale` query param. For example:
227
-
228
- ```https://yourdomain.cool/api/navigation/render/1?locale=fr```
229
-
230
- or
231
-
232
- ```https://yourdomain.cool/api/navigation/render/main-navigation?locale=fr```
233
-
234
- If `locale` is not specified whatever version used to be at id `1` will be returned.
235
-
236
- Of course if you know that `fr` version is present at id `2` you can just query for that.
237
-
238
- ### GraphQL
239
-
240
- If feature is enabled GQL render navigation query is expanded to handle `locale` param(it will work the same as regular requests). Checkout schema provided by GraphQL plugin.
212
+ Fully integrated and follows the **[official i18n Strapi patterns](https://docs.strapi.io/dev-docs/i18n)**.
241
213
 
242
214
  ## 👤 RBAC
243
215
  Plugin provides granular permissions based on **Strapi RBAC** functionality within the editorial interface &amp; **Admin API**. Those settings are editable via the _Setings_ -> _Administration Panel_ -> _Roles_.
@@ -275,6 +247,7 @@ Is applied for **Public API** both for REST and GraphQL. You can manage is by tw
275
247
  ```json
276
248
  {
277
249
  "id": 1,
250
+ "documentId": "njx99iv4p4txuqp307ye8625",
278
251
  "title": "News",
279
252
  "type": "INTERNAL",
280
253
  "path": "news",
@@ -342,17 +315,17 @@ Plugin supports both **REST API** and **GraphQL API** exposed by Strapi.
342
315
 
343
316
  - `navigationIdOrSlug` - ID or slug for which your navigation structure is generated like for REST API:
344
317
 
345
- > `https://localhost:1337/api/navigation/render/1`
318
+ > `https://localhost:1337/api/navigation/render/njx99iv4p4txuqp307ye8625`
346
319
  > `https://localhost:1337/api/navigation/render/main-menu`
347
320
 
348
321
  - `type` - Enum value representing structure type of returned navigation:
349
- > `https://localhost:1337/api/navigation/render/1?type=FLAT`
322
+ > `https://localhost:1337/api/navigation/render/njx99iv4p4txuqp307ye8625?type=FLAT`
350
323
 
351
324
  - `menu` (`menuOnly` for GQL) - Boolean value for querying only navigation items that are attached to menu should be rendered eg.
352
- > `https://localhost:1337/api/navigation/render/1?menu=true`
325
+ > `https://localhost:1337/api/navigation/render/njx99iv4p4txuqp307ye8625?menu=true`
353
326
 
354
327
  - `path` - String value for querying navigation items by its path:
355
- > `https://localhost:1337/api/navigation/render/1?path=/home/about-us`
328
+ > `https://localhost:1337/api/navigation/render/njx99iv4p4txuqp307ye8625?path=/home/about-us`
356
329
 
357
330
  ### REST API
358
331
 
@@ -368,6 +341,7 @@ NOTE: All params are optional
368
341
  [
369
342
  {
370
343
  "id": 383,
344
+ "documentId": "njx99iv4p4txuqp307ye8625",
371
345
  "name": "Floor",
372
346
  "slug": "floor-pl",
373
347
  "visible": true,
@@ -377,6 +351,7 @@ NOTE: All params are optional
377
351
  },
378
352
  {
379
353
  "id": 384,
354
+ "documentId": "njx99iv4p4txuqp307ye8625",
380
355
  "name": "Floor",
381
356
  "slug": "floor-fr",
382
357
  "visible": true,
@@ -386,6 +361,7 @@ NOTE: All params are optional
386
361
  },
387
362
  {
388
363
  "id": 382,
364
+ "documentId": "njx99iv4p4txuqp307ye8625",
389
365
  "name": "Floor",
390
366
  "slug": "floor",
391
367
  "visible": true,
@@ -395,6 +371,7 @@ NOTE: All params are optional
395
371
  },
396
372
  {
397
373
  "id": 374,
374
+ "documentId": "njx99iv4p4txuqp307ye8625",
398
375
  "name": "Main navigation",
399
376
  "slug": "main-navigation-pl",
400
377
  "visible": true,
@@ -404,6 +381,7 @@ NOTE: All params are optional
404
381
  },
405
382
  {
406
383
  "id": 375,
384
+ "documentId": "njx99iv4p4txuqp307ye8625",
407
385
  "name": "Main navigation",
408
386
  "slug": "main-navigation-fr",
409
387
  "visible": true,
@@ -413,6 +391,7 @@ NOTE: All params are optional
413
391
  },
414
392
  {
415
393
  "id": 373,
394
+ "documentId": "njx99iv4p4txuqp307ye8625",
416
395
  "name": "Main navigation",
417
396
  "slug": "main-navigation",
418
397
  "visible": true,
@@ -427,9 +406,7 @@ NOTE: All params are optional
427
406
 
428
407
  Return a rendered navigation structure depends on passed type (`TREE`, `RFR` or nothing to render as `FLAT`).
429
408
 
430
- > The ID of navigation by default is `1`, if you've got defined multiple navigations you must work with their IDs or Slugs to fetch.
431
-
432
- **Example URL**: `https://localhost:1337/api/navigation/render/1`
409
+ **Example URL**: `https://localhost:1337/api/navigation/render/njx99iv4p4txuqp307ye8625`
433
410
 
434
411
  **Example response body**
435
412
 
@@ -437,6 +414,7 @@ Return a rendered navigation structure depends on passed type (`TREE`, `RFR` or
437
414
  [
438
415
  {
439
416
  "id": 1,
417
+ "documentId": "njx99iv4p4txuqp307ye8625",
440
418
  "title": "News",
441
419
  "type": "INTERNAL",
442
420
  "path": "news",
@@ -450,6 +428,7 @@ Return a rendered navigation structure depends on passed type (`TREE`, `RFR` or
450
428
  "related": {
451
429
  "__contentType": "Page",
452
430
  "id": 1,
431
+ "documentId": "njx99iv4p4txuqp307ye8625",
453
432
  "title": "News",
454
433
  // ...
455
434
  }
@@ -458,7 +437,7 @@ Return a rendered navigation structure depends on passed type (`TREE`, `RFR` or
458
437
  ]
459
438
  ```
460
439
 
461
- **Example URL**: `https://localhost:1337/api/navigation/render/1?type=TREE`
440
+ **Example URL**: `https://localhost:1337/api/navigation/render/njx99iv4p4txuqp307ye8625?type=TREE`
462
441
 
463
442
  **Example response body**
464
443
 
@@ -494,7 +473,7 @@ Return a rendered navigation structure depends on passed type (`TREE`, `RFR` or
494
473
  ]
495
474
  ```
496
475
 
497
- **Example URL**: `https://localhost:1337/api/navigation/render/1?type=RFR`
476
+ **Example URL**: `https://localhost:1337/api/navigation/render/njx99iv4p4txuqp307ye8625?type=RFR`
498
477
 
499
478
  **Example response body**
500
479
 
@@ -743,11 +722,13 @@ Example:
743
722
 
744
723
  ## 🧹 REST Cache
745
724
 
725
+ > Note: Yet using the `4.x` compatible version of the plugin. Integration migration expected once the maintenance team release their `5.x` compatible version.
726
+
746
727
  If your strapi server uses [REST Cache plugin](https://strapi-community.github.io/strapi-plugin-rest-cache/) this plugin can take integrate with it. All you need to do is to enable it in configuration of Navigation plugin. After integration is enabled all client calls will be wrapped with caching middleware.
747
728
 
748
729
  In admin panel new controls will be available. Cache clearing is done manually or after cache will timeout(`rest-cache` plugin's settings are used).
749
730
 
750
- Navigation edit screen will have "Clear cache" button.
731
+ Navigation edit screen will have **"Clear cache"** button.
751
732
 
752
733
  Navigation management modal items will also have icon button for clearing the cache.
753
734
 
@@ -759,11 +740,11 @@ Live example of plugin usage can be found in the [VirtusLab Strapi Examples](htt
759
740
 
760
741
  ### GraphQL tricks
761
742
 
762
- **Q:** I would like to use GraphQL schemas but I'm not getting renderNavigation query or even proper types as Navigation, NavigationItem etc. What should I do?
743
+ **Q:** I would like to use GraphQL schemas but I'm not getting `renderNavigation` query or even proper types as Navigation, NavigationItem etc. What should I do?
763
744
 
764
- **A:** There is a one trick you might try. Strapi by default is ordering plugins by the way which takes `strapi-plugin-graphql` to initialize earlier than other plugins so types might not be injected. If you don't have it yet, please create `config/plugins.js` file and put there following lines (put `graphql` at the end):
745
+ **A:** There is a one trick you might try. Strapi by default is ordering plugins by the way which takes `strapi-plugin-graphql` to initialize earlier than other plugins so types might not be injected. If you don't have it yet, please create `config/plugins.{js,ts}` file and put there following lines (put `graphql` at the end):
765
746
 
766
- ```js
747
+ ```ts
767
748
  module.exports = {
768
749
  'navigation': { enabled: true },
769
750
  'graphql': { enabled: true },