strapi-plugin-navigation 3.0.14 → 3.0.16
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 +221 -209
- package/dist/_chunks/{ca-BzGBgdJx.js → ca-Gq9Ty_aG.js} +1 -1
- package/dist/_chunks/{ca-DVB9tv4s.mjs → ca-Jr1amAtF.mjs} +7 -0
- package/dist/_chunks/{en-CKowl_sX.js → en-BP5RWE-N.js} +1 -1
- package/dist/_chunks/{en--XL9UqS_.mjs → en-DmeenfQT.mjs} +7 -0
- package/dist/_chunks/{fr-BjVniZne.js → fr-BIJn6QmK.js} +1 -1
- package/dist/_chunks/{fr-B3UeLLGy.mjs → fr-CZx3EMw8.mjs} +7 -0
- package/dist/admin/index.js +295 -275
- package/dist/admin/index.mjs +8023 -7877
- package/dist/admin/src/pages/HomePage/components/ChangeLanguageDialog/index.d.ts +13 -0
- package/dist/admin/src/pages/HomePage/components/ControllableCombobox/index.d.ts +1 -1
- package/dist/admin/src/pages/HomePage/components/NavigationHeader/index.d.ts +1 -0
- package/dist/admin/src/pages/HomePage/components/NavigationItemForm/utils/form.d.ts +3 -3
- package/dist/admin/src/pages/SettingsPage/common/index.d.ts +1 -1
- package/dist/admin/src/translations/ca.d.ts +7 -0
- package/dist/admin/src/translations/en.d.ts +7 -0
- package/dist/admin/src/translations/es.d.ts +7 -0
- package/dist/admin/src/translations/fr.d.ts +7 -0
- package/dist/admin/src/translations/tr.d.ts +7 -0
- package/dist/server/index.js +26 -26
- package/dist/server/index.mjs +1232 -1210
- package/dist/server/src/config/setup.d.ts +1 -1
- package/dist/server/src/graphql/index.d.ts +1 -1
- package/dist/server/src/repositories/navigation-item.d.ts +2 -0
- package/dist/server/src/schemas/navigation.d.ts +5 -5
- package/dist/server/src/services/common/utils.d.ts +1 -0
- package/package.json +6 -8
package/README.md
CHANGED
|
@@ -31,19 +31,20 @@ Strapi Navigation Plugin provides a website navigation / menu builder feature fo
|
|
|
31
31
|
- RFR (ready for handling by Redux First Router)
|
|
32
32
|
|
|
33
33
|
### Table of Contents
|
|
34
|
+
|
|
34
35
|
1. [💎 Versions](#-versions)
|
|
35
36
|
2. [✨ Features](#-features)
|
|
36
37
|
3. [⏳ Installation](#-installation)
|
|
37
38
|
4. [🖐 Requirements](#-requirements)
|
|
38
39
|
5. [🔧 Basic Configuration](#-configuration)
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
- [Settings page](#in-v203-and-newer)
|
|
41
|
+
- [Plugin file](#in-v202-and-older--default-configuration-state-for-v203-and-newer)
|
|
41
42
|
6. [🔧 GraphQL Configuration](#-gql-configuration)
|
|
42
43
|
7. [👤 RBAC](#-rbac)
|
|
43
44
|
8. [🔐 Authorization strategy](#-authorization-strategy)
|
|
44
45
|
9. [🕸️ Public API specification](#%EF%B8%8F-public-api-specification)
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
- [REST API](#rest-api)
|
|
47
|
+
- [GraphQL API](#graphql-api)
|
|
47
48
|
10. [🔌 Extensions](#-extensions)
|
|
48
49
|
11. [🌿 Model lifecycle hooks](#model-life-cycle-hooks)
|
|
49
50
|
12. [🧹 REST Cache](#rest-cache)
|
|
@@ -63,10 +64,10 @@ Strapi Navigation Plugin provides a website navigation / menu builder feature fo
|
|
|
63
64
|
- **Navigation Public API:** Simple and ready for use API endpoint for consuming the navigation structure you've created
|
|
64
65
|
- **Visual builder:** Elegant and easy to use visual builder
|
|
65
66
|
- **Any Content Type relation:** Navigation can by linked to any of your Content Types by default. Simply, you're controlling it and also limiting available content types by configuration props
|
|
66
|
-
- **Different types of navigation items:** Create navigation with items linked to internal types, to external links or wrapper elements to keep structure clean
|
|
67
|
+
- **Different types of navigation items:** Create navigation with items linked to internal types, to external links or wrapper elements to keep structure clean
|
|
67
68
|
- **Multiple navigations:** Create as many Navigation containers as you want, setup them and use in the consumer application
|
|
68
|
-
- **Light / Dark mode compatible:** By design we're supporting Strapi ☀️ Light / 🌙 Dark modes
|
|
69
|
-
- **Webhooks integration:** Changes to navigation will trigger 'entry.update' or 'entry.create' webhook events.
|
|
69
|
+
- **Light / Dark mode compatible:** By design we're supporting Strapi ☀️ Light / 🌙 Dark modes
|
|
70
|
+
- **Webhooks integration:** Changes to navigation will trigger 'entry.update' or 'entry.create' webhook events.
|
|
70
71
|
- **Customizable:** Possibility to customize the options like: available Content Types, Maximum level for "attach to menu", Additional fields (audience)
|
|
71
72
|
|
|
72
73
|
## ⏳ Installation
|
|
@@ -131,13 +132,12 @@ On the dedicated page, you will be able to set up all crucial properties which d
|
|
|
131
132
|
<img style="width: 100%; height: auto;" src="https://www.sensinum.com/img/open-source/strapi-plugin-navigation/configuration.png" alt="Plugin configuration" />
|
|
132
133
|
</div>
|
|
133
134
|
|
|
134
|
-
>
|
|
135
|
+
> _Note_
|
|
135
136
|
> The default configuration for your plugin is fetched from `config/plugins.js` or, if the file is not there, directly from the plugin itself. If you would like to customize the default state to which you might revert, please follow the next section.
|
|
136
137
|
|
|
137
138
|
### File
|
|
138
139
|
|
|
139
|
-
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.
|
|
140
|
-
|
|
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.
|
|
141
141
|
|
|
142
142
|
```ts
|
|
143
143
|
module.exports = ({ env }) => ({
|
|
@@ -161,6 +161,7 @@ Config for this plugin is stored as a part of the `config/plugins.{js|ts}` or `c
|
|
|
161
161
|
```
|
|
162
162
|
|
|
163
163
|
### Properties
|
|
164
|
+
|
|
164
165
|
- `additionalFields` - Additional fields for navigation items. More **[ here ](#additional-fields)**
|
|
165
166
|
- `allowedLevels` - Maximum level for which you're able to mark item as "Menu attached"
|
|
166
167
|
- `contentTypes` - UIDs of related content types
|
|
@@ -172,12 +173,14 @@ Config for this plugin is stored as a part of the `config/plugins.{js|ts}` or `c
|
|
|
172
173
|
### Properties
|
|
173
174
|
|
|
174
175
|
### Additional Fields
|
|
175
|
-
|
|
176
|
+
|
|
177
|
+
It is advised to configure additional fields through the plugin's Settings Page. There you can find the table of custom fields and toggle input for the audience field. When enabled, the audience field can be customized through the content manager. Custom fields can be added, edited, toggled, and removed with the use of the table provided on the Settings Page. When removing custom fields be advised that their values in navigation items will be lost. Disabling the custom fields will not affect the data and can be done with no consequence of loosing information.
|
|
176
178
|
|
|
177
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' | 'media', name: string, label: string, enabled?: boolean }`. 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.
|
|
178
180
|
|
|
179
181
|
## 🔧 GQL Configuration
|
|
180
|
-
|
|
182
|
+
|
|
183
|
+
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:
|
|
181
184
|
|
|
182
185
|
> **Important!**
|
|
183
186
|
> 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.
|
|
@@ -188,7 +191,7 @@ items: [NavigationItem]
|
|
|
188
191
|
related: NavigationRelated
|
|
189
192
|
```
|
|
190
193
|
|
|
191
|
-
This prop should look as follows:
|
|
194
|
+
This prop should look as follows:
|
|
192
195
|
|
|
193
196
|
```ts
|
|
194
197
|
gql: {
|
|
@@ -196,35 +199,42 @@ gql: {
|
|
|
196
199
|
},
|
|
197
200
|
```
|
|
198
201
|
|
|
199
|
-
for example:
|
|
202
|
+
for example:
|
|
200
203
|
|
|
201
204
|
```ts
|
|
202
205
|
gql: {
|
|
203
206
|
navigationItemRelated: ['Page', 'UploadFile'],
|
|
204
207
|
},
|
|
205
208
|
```
|
|
209
|
+
|
|
206
210
|
where `Page` and `UploadFile` are your type names for the **Content Types** you're referring by navigation items relations.
|
|
207
211
|
|
|
208
212
|
## 👤 RBAC
|
|
213
|
+
|
|
209
214
|
Plugin provides granular permissions based on **Strapi RBAC** functionality within the editorial interface & **Admin API**. Those settings are editable via the _Setings_ -> _Administration Panel_ -> _Roles_.
|
|
210
215
|
|
|
211
216
|
For any role different than **Super Admin**, to access the **Navigation panel** you must set following permissions:
|
|
212
217
|
|
|
213
218
|
### Mandatory permissions
|
|
219
|
+
|
|
214
220
|
- _Plugins_ -> _Navigation_ -> _Read_ - gives you the access to **Navigation Panel**
|
|
215
221
|
|
|
216
222
|
### Other permissions
|
|
223
|
+
|
|
217
224
|
- _Plugins_ -> _Navigation_ -> _Update_ - with this permission user is able to change Navigation structure
|
|
218
225
|
- _Plugins_ -> _Navigation_ -> _Settings_ - special permission for users that should be able to change plugin settings
|
|
219
226
|
|
|
220
227
|
## 🔐 Authorization strategy
|
|
221
|
-
|
|
228
|
+
|
|
229
|
+
Is applied for **Public API** both for REST and GraphQL. You can manage is by two different ways. Those settings are editable via the _Setings_ -> _Users & Permissions Plugin_ -> _Roles_.
|
|
222
230
|
|
|
223
231
|
## User based
|
|
232
|
+
|
|
224
233
|
- _Public_ - as per description it's default role for any not authenticated user. By enabling **Public API** of the plugin here you're making it **fully public**, without **any permissions check**.
|
|
225
234
|
- _Authenticated_ - as per description this is default role for Strapi Users. If you enable **Public API** here, for any call made you must use the User authentication token as `Bearer <token>`.
|
|
226
235
|
|
|
227
236
|
## Token based
|
|
237
|
+
|
|
228
238
|
- _Full Access_ - gives full access to every Strapi Content API including our plugin endpoints as well.
|
|
229
239
|
- _Custom_ - granural access management to every Strapi Content API endpoints as well as plugin **Public API** - _(recomended approach)_
|
|
230
240
|
|
|
@@ -238,66 +248,71 @@ Is applied for **Public API** both for REST and GraphQL. You can manage is by tw
|
|
|
238
248
|
## Base Navigation Item model
|
|
239
249
|
|
|
240
250
|
### Flat
|
|
251
|
+
|
|
241
252
|
```json
|
|
242
253
|
{
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
254
|
+
"id": 1,
|
|
255
|
+
"documentId": "njx99iv4p4txuqp307ye8625",
|
|
256
|
+
"title": "News",
|
|
257
|
+
"type": "INTERNAL",
|
|
258
|
+
"path": "news",
|
|
259
|
+
"externalPath": null,
|
|
260
|
+
"uiRouterKey": "News",
|
|
261
|
+
"menuAttached": false,
|
|
262
|
+
"parent": 8, // Parent Navigation Item 'id', null in case of root level
|
|
263
|
+
"master": 1, // Navigation 'id'
|
|
264
|
+
"createdAt": "2020-09-29T13:29:19.086Z",
|
|
265
|
+
"updatedAt": "2020-09-29T13:29:19.128Z",
|
|
266
|
+
"related": {
|
|
267
|
+
/*<Content Type model >*/
|
|
268
|
+
},
|
|
269
|
+
"audience": []
|
|
257
270
|
}
|
|
258
271
|
```
|
|
259
272
|
|
|
260
273
|
### Tree
|
|
274
|
+
|
|
261
275
|
```json
|
|
262
276
|
{
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
277
|
+
"title": "News",
|
|
278
|
+
"menuAttached": true,
|
|
279
|
+
"path": "/news",
|
|
280
|
+
"type": "INTERNAL",
|
|
281
|
+
"uiRouterKey": "news",
|
|
282
|
+
"slug": "benefits",
|
|
283
|
+
"external": false,
|
|
284
|
+
"related": {
|
|
285
|
+
// <Content Type model >
|
|
286
|
+
},
|
|
287
|
+
"items": [
|
|
288
|
+
{
|
|
289
|
+
"title": "External url",
|
|
290
|
+
"menuAttached": true,
|
|
291
|
+
"path": "http://example.com",
|
|
292
|
+
"type": "EXTERNAL",
|
|
293
|
+
"uiRouterKey": "generic",
|
|
294
|
+
"external": true
|
|
295
|
+
}
|
|
296
|
+
// < Tree Navigation Item models >
|
|
297
|
+
]
|
|
284
298
|
}
|
|
285
299
|
```
|
|
286
300
|
|
|
287
301
|
### RFR
|
|
302
|
+
|
|
288
303
|
```json
|
|
289
304
|
{
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
305
|
+
"id": "News",
|
|
306
|
+
"title": "News",
|
|
307
|
+
"related": {
|
|
308
|
+
"contentType": "page",
|
|
309
|
+
"collectionName": "pages",
|
|
310
|
+
"id": 1
|
|
311
|
+
},
|
|
312
|
+
"path": "/news",
|
|
313
|
+
"slug": "news",
|
|
314
|
+
"parent": null, // Parent Navigation Item 'id', null in case of root level
|
|
315
|
+
"menuAttached": true
|
|
301
316
|
}
|
|
302
317
|
```
|
|
303
318
|
|
|
@@ -309,13 +324,14 @@ Plugin supports both **REST API** and **GraphQL API** exposed by Strapi.
|
|
|
309
324
|
|
|
310
325
|
- `navigationIdOrSlug` - ID or slug for which your navigation structure is generated like for REST API:
|
|
311
326
|
|
|
312
|
-
> `https://localhost:1337/api/navigation/render/njx99iv4p4txuqp307ye8625`
|
|
313
|
-
> `https://localhost:1337/api/navigation/render/main-menu`
|
|
327
|
+
> `https://localhost:1337/api/navigation/render/njx99iv4p4txuqp307ye8625` > `https://localhost:1337/api/navigation/render/main-menu`
|
|
314
328
|
|
|
315
329
|
- `type` - Enum value representing structure type of returned navigation:
|
|
330
|
+
|
|
316
331
|
> `https://localhost:1337/api/navigation/render/njx99iv4p4txuqp307ye8625?type=FLAT`
|
|
317
332
|
|
|
318
333
|
- `menu` (`menuOnly` for GQL) - Boolean value for querying only navigation items that are attached to menu should be rendered eg.
|
|
334
|
+
|
|
319
335
|
> `https://localhost:1337/api/navigation/render/njx99iv4p4txuqp307ye8625?menu=true`
|
|
320
336
|
|
|
321
337
|
- `path` - String value for querying navigation items by its path:
|
|
@@ -406,28 +422,28 @@ Return a rendered navigation structure depends on passed type (`TREE`, `RFR` or
|
|
|
406
422
|
|
|
407
423
|
```json
|
|
408
424
|
[
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
425
|
+
{
|
|
426
|
+
"id": 1,
|
|
427
|
+
"documentId": "njx99iv4p4txuqp307ye8625",
|
|
428
|
+
"title": "News",
|
|
429
|
+
"type": "INTERNAL",
|
|
430
|
+
"path": "news",
|
|
431
|
+
"externalPath": null,
|
|
432
|
+
"uiRouterKey": "News",
|
|
433
|
+
"menuAttached": false,
|
|
434
|
+
"parent": null,
|
|
435
|
+
"master": 1,
|
|
436
|
+
"created_at": "2020-09-29T13:29:19.086Z",
|
|
437
|
+
"updated_at": "2020-09-29T13:29:19.128Z",
|
|
438
|
+
"related": {
|
|
439
|
+
"__contentType": "Page",
|
|
440
|
+
"id": 1,
|
|
441
|
+
"documentId": "njx99iv4p4txuqp307ye8625",
|
|
442
|
+
"title": "News"
|
|
443
|
+
// ...
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
// ...
|
|
431
447
|
]
|
|
432
448
|
```
|
|
433
449
|
|
|
@@ -437,33 +453,33 @@ Return a rendered navigation structure depends on passed type (`TREE`, `RFR` or
|
|
|
437
453
|
|
|
438
454
|
```json
|
|
439
455
|
[
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
},
|
|
454
|
-
"items": [
|
|
455
|
-
{
|
|
456
|
-
"title": "External url",
|
|
457
|
-
"menuAttached": true,
|
|
458
|
-
"path": "http://example.com",
|
|
459
|
-
"type": "EXTERNAL",
|
|
460
|
-
"uiRouterKey": "generic",
|
|
461
|
-
"external": true
|
|
462
|
-
},
|
|
463
|
-
// ...
|
|
464
|
-
]
|
|
456
|
+
{
|
|
457
|
+
"title": "News",
|
|
458
|
+
"menuAttached": true,
|
|
459
|
+
"path": "/news",
|
|
460
|
+
"type": "INTERNAL",
|
|
461
|
+
"uiRouterKey": "news",
|
|
462
|
+
"slug": "benefits",
|
|
463
|
+
"external": false,
|
|
464
|
+
"related": {
|
|
465
|
+
"__contentType": "Page",
|
|
466
|
+
"id": 1,
|
|
467
|
+
"title": "News"
|
|
468
|
+
// ...
|
|
465
469
|
},
|
|
466
|
-
|
|
470
|
+
"items": [
|
|
471
|
+
{
|
|
472
|
+
"title": "External url",
|
|
473
|
+
"menuAttached": true,
|
|
474
|
+
"path": "http://example.com",
|
|
475
|
+
"type": "EXTERNAL",
|
|
476
|
+
"uiRouterKey": "generic",
|
|
477
|
+
"external": true
|
|
478
|
+
}
|
|
479
|
+
// ...
|
|
480
|
+
]
|
|
481
|
+
}
|
|
482
|
+
// ...
|
|
467
483
|
]
|
|
468
484
|
```
|
|
469
485
|
|
|
@@ -473,77 +489,77 @@ Return a rendered navigation structure depends on passed type (`TREE`, `RFR` or
|
|
|
473
489
|
|
|
474
490
|
```json
|
|
475
491
|
{
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
},
|
|
490
|
-
"Community": {
|
|
491
|
-
"id": "Community",
|
|
492
|
-
"title": "Community",
|
|
493
|
-
"related": {
|
|
494
|
-
"contentType": "page",
|
|
495
|
-
"collectionName": "pages",
|
|
496
|
-
"id": 2
|
|
497
|
-
},
|
|
498
|
-
"path": "/community",
|
|
499
|
-
"slug": "community",
|
|
500
|
-
"parent": null,
|
|
501
|
-
"menuAttached": true
|
|
502
|
-
},
|
|
503
|
-
"Highlights": {
|
|
504
|
-
"id": "Highlights",
|
|
505
|
-
"title": "Highlights",
|
|
506
|
-
"related": {
|
|
507
|
-
"contentType": "page",
|
|
508
|
-
"collectionName": "pages",
|
|
509
|
-
"id": 3
|
|
510
|
-
},
|
|
511
|
-
"path": "/community/highlights",
|
|
512
|
-
"slug": "community-highlights",
|
|
513
|
-
"parent": "Community",
|
|
514
|
-
"menuAttached": false
|
|
515
|
-
},
|
|
516
|
-
// ...
|
|
492
|
+
"pages": {
|
|
493
|
+
"News": {
|
|
494
|
+
"id": "News",
|
|
495
|
+
"title": "News",
|
|
496
|
+
"related": {
|
|
497
|
+
"contentType": "page",
|
|
498
|
+
"collectionName": "pages",
|
|
499
|
+
"id": 1
|
|
500
|
+
},
|
|
501
|
+
"path": "/news",
|
|
502
|
+
"slug": "news",
|
|
503
|
+
"parent": null,
|
|
504
|
+
"menuAttached": true
|
|
517
505
|
},
|
|
518
|
-
"
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
"
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
// ...
|
|
544
|
-
],
|
|
545
|
-
// ...
|
|
506
|
+
"Community": {
|
|
507
|
+
"id": "Community",
|
|
508
|
+
"title": "Community",
|
|
509
|
+
"related": {
|
|
510
|
+
"contentType": "page",
|
|
511
|
+
"collectionName": "pages",
|
|
512
|
+
"id": 2
|
|
513
|
+
},
|
|
514
|
+
"path": "/community",
|
|
515
|
+
"slug": "community",
|
|
516
|
+
"parent": null,
|
|
517
|
+
"menuAttached": true
|
|
518
|
+
},
|
|
519
|
+
"Highlights": {
|
|
520
|
+
"id": "Highlights",
|
|
521
|
+
"title": "Highlights",
|
|
522
|
+
"related": {
|
|
523
|
+
"contentType": "page",
|
|
524
|
+
"collectionName": "pages",
|
|
525
|
+
"id": 3
|
|
526
|
+
},
|
|
527
|
+
"path": "/community/highlights",
|
|
528
|
+
"slug": "community-highlights",
|
|
529
|
+
"parent": "Community",
|
|
530
|
+
"menuAttached": false
|
|
546
531
|
}
|
|
532
|
+
// ...
|
|
533
|
+
},
|
|
534
|
+
"nav": {
|
|
535
|
+
"root": [
|
|
536
|
+
{
|
|
537
|
+
"label": "News",
|
|
538
|
+
"type": "internal",
|
|
539
|
+
"page": "News"
|
|
540
|
+
},
|
|
541
|
+
{
|
|
542
|
+
"label": "Community",
|
|
543
|
+
"type": "internal",
|
|
544
|
+
"page": "Community"
|
|
545
|
+
},
|
|
546
|
+
{
|
|
547
|
+
"label": "External url",
|
|
548
|
+
"type": "external",
|
|
549
|
+
"url": "http://example.com"
|
|
550
|
+
}
|
|
551
|
+
// ...
|
|
552
|
+
],
|
|
553
|
+
"Community": [
|
|
554
|
+
{
|
|
555
|
+
"label": "Highlights",
|
|
556
|
+
"type": "internal",
|
|
557
|
+
"page": "Highlights"
|
|
558
|
+
}
|
|
559
|
+
// ...
|
|
560
|
+
]
|
|
561
|
+
// ...
|
|
562
|
+
}
|
|
547
563
|
}
|
|
548
564
|
```
|
|
549
565
|
|
|
@@ -555,11 +571,7 @@ Same as [**REST API**](#rest-api) returns a rendered navigation structure depend
|
|
|
555
571
|
|
|
556
572
|
```graphql
|
|
557
573
|
query {
|
|
558
|
-
renderNavigation(
|
|
559
|
-
navigationIdOrSlug: "main-navigation"
|
|
560
|
-
type: TREE
|
|
561
|
-
menuOnly: false
|
|
562
|
-
) {
|
|
574
|
+
renderNavigation(navigationIdOrSlug: "main-navigation", type: TREE, menuOnly: false) {
|
|
563
575
|
id
|
|
564
576
|
title
|
|
565
577
|
path
|
|
@@ -653,10 +665,10 @@ For example:
|
|
|
653
665
|
module.exports = {
|
|
654
666
|
// ...
|
|
655
667
|
bootstrap({ strapi }) {
|
|
656
|
-
const navigationCommonService = strapi.plugin(
|
|
668
|
+
const navigationCommonService = strapi.plugin('navigation').service('common');
|
|
657
669
|
const originalGetSlug = navigationCommonService.getSlug;
|
|
658
670
|
const preprocess = (q) => {
|
|
659
|
-
return q +
|
|
671
|
+
return q + 'suffix';
|
|
660
672
|
};
|
|
661
673
|
|
|
662
674
|
navigationCommonService.getSlug = (query) => {
|
|
@@ -676,34 +688,32 @@ Lifecycle hooks can be register either in `register()` or `bootstrap()` methods
|
|
|
676
688
|
|
|
677
689
|
Listeners can by sync and `async`.
|
|
678
690
|
|
|
679
|
-
>Be aware that lifecycle hooks registered in `register()` may be fired by plugin's bootstrapping. If you want listen to events triggered after server's startup use `bootstrap()`.
|
|
691
|
+
> Be aware that lifecycle hooks registered in `register()` may be fired by plugin's bootstrapping. If you want listen to events triggered after server's startup use `bootstrap()`.
|
|
680
692
|
|
|
681
693
|
Example:
|
|
682
694
|
|
|
683
695
|
```ts
|
|
684
|
-
|
|
685
|
-
.plugin("navigation")
|
|
686
|
-
.service("common");
|
|
696
|
+
const navigationCommonService = strapi.plugin('navigation').service('common');
|
|
687
697
|
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
698
|
+
navigationCommonService.registerLifecycleHook({
|
|
699
|
+
callback: async ({ action, result }) => {
|
|
700
|
+
const saveResult = await logIntoSystem(action, result);
|
|
691
701
|
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
702
|
+
console.log(saveResult);
|
|
703
|
+
},
|
|
704
|
+
contentTypeName: 'navigation',
|
|
705
|
+
hookName: 'afterCreate',
|
|
706
|
+
});
|
|
697
707
|
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
708
|
+
navigationCommonService.registerLifecycleHook({
|
|
709
|
+
callback: async ({ action, result }) => {
|
|
710
|
+
const saveResult = await logIntoSystem(action, result);
|
|
701
711
|
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
712
|
+
console.log(saveResult);
|
|
713
|
+
},
|
|
714
|
+
contentTypeName: 'navigation-item',
|
|
715
|
+
hookName: 'afterCreate',
|
|
716
|
+
});
|
|
707
717
|
```
|
|
708
718
|
|
|
709
719
|
## 🧹 REST Cache
|
|
@@ -732,8 +742,8 @@ Live example of plugin usage can be found in the [VirtusLab Strapi Examples](htt
|
|
|
732
742
|
|
|
733
743
|
```ts
|
|
734
744
|
module.exports = {
|
|
735
|
-
|
|
736
|
-
|
|
745
|
+
navigation: { enabled: true },
|
|
746
|
+
graphql: { enabled: true },
|
|
737
747
|
};
|
|
738
748
|
```
|
|
739
749
|
|
|
@@ -775,9 +785,11 @@ Feel free to fork and make a Pull Request to this plugin project. All the input
|
|
|
775
785
|
4. Run your Strapi instance
|
|
776
786
|
|
|
777
787
|
### :octocat: Core team
|
|
788
|
+
|
|
778
789
|
[@CodeVoyager](https://github.com/CodeVoyager) [@cyp3rius](https://github.com/cyp3rius)
|
|
779
790
|
|
|
780
791
|
### 🌟 Strapi Community
|
|
792
|
+
|
|
781
793
|
[@jorrit](https://github.com/jorrit)
|
|
782
794
|
|
|
783
795
|
## 👨💻 Community support
|