mattmilburn / strapi-plugin-menus

A plugin for Strapi CMS to customize the structure of menus and menu items.
MIT License
110 stars 27 forks source link

TypeError: Cannot read properties of undefined (reading 'schema') #147

Open sergheiCovali opened 8 months ago

sergheiCovali commented 8 months ago

I've added strapi-server.js in src/extensions/menus/

// ./src/extensions/menus/strapi-server.js` "use strict";

module.exports = (plugin) => { // Get current MenuItem attributes. const defaultAttrs = plugin.contentTypes["'menu-item'"].schema.attributes;

// Define custom attributes for MenuItem the same way they would be defined // on any other schema. const customAttrs = { short_description: { type: "string", }, };

// Extend the MenuItem content type with custom attributes. plugin.contentTypes["'menu-item'"].schema.attributes = { ...defaultAttrs, ...customAttrs, };

return plugin; };

after this when I run -> npm run develop strapi I get this error

TypeError: Cannot read properties of undefined (reading 'schema') ││ at module.exports (/Users..../../../../src ││ /extensions/menus/strapi-server.js:6:58) ││ at applyUserExtension

mattmilburn commented 8 months ago

Hi @sergheiCovali This extension portion of your code looks okay. Can you provide more details from your package.json and config/plugins.js? The error suggests the MenuItem content type isn't registered with Strapi but it should be.