一个用于 Strapi Headless CMS 的插件,提供导航/菜单构建功能,并允许用户控制受众和不同的输出结构。
一个用于 Strapi Headless CMS 的插件,提供导航/菜单构建功能,并允许用户控制受众和不同的输出结构。
Strapi Navigation Plugin provides a website navigation / menu builder feature for Strapi Headless CMS admin panel. Navigation has the possibility to control the audience and can be consumed by the website with different output structure renderers:
As a ✅ verified plugin by Strapi team we're available on the Strapi Marketplace as well as In-App Marketplace where you can follow the installation instructions.
It's recommended to use yarn to install this plugin within your Strapi project. You can install yarn with these docs.
yarn add strapi-plugin-navigation@latestAfter successful installation you've to re-build your Strapi instance. To archive that simply use:
yarn build
yarn developThe UI Navigation plugin should appear in the Plugins section of Strapi sidebar after you run app again.
You can manage your multiple navigation containers by going to the Navigation manage view by clicking "Manage" button.
As a next step you must configure your the plugin by the way you want to. See Configuration section.
All done. Enjoy
Complete installation requirements are exact same as for Strapi itself and can be found in the documentation under Installation Requirements.
Supported Strapi versions:
This plugin is designed for Strapi v5 and is not working with v4.x. To get version for Strapi v4 install version v4.x.
We recommend always using the latest version of Strapi to start your new projects.
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.
On the dedicated page, you will be able to set up all crucial properties which drive the plugin and customize each individual collection for which Navigation plugin should be enabled.
Note The default configuration for your plugin is fetched from
config/plugins.jsor, 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.
Config for this plugin is stored as a part of the config/plugins.{js|ts} or config//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.
…additionalFields - Additional fields for navigation items. More here allowedLevels - Maximum level for which you're able to mark item as "Menu attached"contentTypes - UIDs of related content typesdefaultContentTypes - UID of content type that will be selected by default while creating a new navigation itemcontentTypesNameFields - Definition of content type title fields like 'api::.': ['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/?page=1&pageSize=10&sort=Title:ASC&plugins[i18n][locale]=enpathDefaultFields - The attribute to copy the default path from per content type. Syntax: 'api::.': ['url_slug', 'path']. If you leave it empty, the default path is generated based on the ID.gql - If you're using GraphQL that's the right place to put all necessary settings. More here cascadeMenuAttached - If you don't want "Menu attached" to cascade on child items set this value Disabled.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.
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, where CustomField is of type
type CustomField =
| {
type: 'string' | 'boolean' | 'media';
name: string;
label: string;
description?: string;
placeholder?: string;
required?: boolean;
enabled?: boolean;
}
| {
type: 'select';
name: string;
label: string;
description?: string;
placeholder?: string;
multi: boolean;
options: string[];
required?: boolean;
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.
Using navigation with GraphQL requires both plugins to be installed and working. You can find installation guide for GraphQL plugin here. 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:
Important! If you're using
config/plugins.jsto configure your plugins , please putnavigationproperty beforegraphql. 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 onbootstrapstage, notregister. This is not valid if you're usinggraphqlplugin without any custom configuration, so most of cases in real.
master: Int
items: [NavigationItem]
related: NavigationRelatedThis prop should look as follows:
gql: {
navigationItemRelated: [''],
},for example:
gql: {
navigationItemRelated: ['Page', 'UploadFile'],
},where Page and UploadFile are your type names for the Content Types you're referring by navigation items relations.
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.
For any role different than Super Admin, to access the Navigation panel you must set following permissions:
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.
Bearer .Note: Token usage & Read-Only tokens If you're aiming to use token based approach, for every call you must provide proper token in headers as
Bearer.Important: As the Read-Only tokens are dedicated to support just
findandfindAllendpoints from Strapi Content API, they are not covering access to plugin Public APIrenderandrenderChildendpoints. We recommend to use theCustomtoken type for fully granural and secured approach instead ofFull Accessones.Reference: Strapi - API Tokens
{
"id": 1,
"documentId": "njx99iv4p4txuqp307ye8625",
"title": "News",
"type": "INTERNAL",
"path": "news",
"externalPath": null,
"uiRouterKey": "News",
"menuAttached": false,
"parent": 8, // Parent Navigation Item 'id', null in case of root level
"master": 1, // Navigation 'id'
"createdAt": "2020-09-29T13:29:19.086Z",
"updatedAt": "2020-09-29T13:29:19.128Z",
"relat暂无开放 Issues,或尚未同步最近议题。