Skip to content

Commit

Permalink
feat: add sub categories
Browse files Browse the repository at this point in the history
  • Loading branch information
pawan-live committed Jan 12, 2025
1 parent 54a655a commit a45a1d1
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/api/category/content-types/category/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"info": {
"singularName": "category",
"pluralName": "categories",
"displayName": "Categories"
"displayName": "Categories",
"description": ""
},
"options": {
"draftAndPublish": true
Expand Down Expand Up @@ -32,6 +33,29 @@
},
"type": "string",
"required": true
},
"subtitle": {
"pluginOptions": {
"i18n": {
"localized": true
}
},
"type": "string"
},
"image": {
"allowedTypes": [
"images",
"files",
"videos",
"audios"
],
"type": "media",
"multiple": false,
"pluginOptions": {
"i18n": {
"localized": true
}
}
}
}
}
35 changes: 35 additions & 0 deletions src/api/subcategory/content-types/subcategory/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"kind": "collectionType",
"collectionName": "subcategories",
"info": {
"singularName": "subcategory",
"pluralName": "subcategories",
"displayName": "subcategories"
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"name": {
"type": "string"
},
"slug": {
"type": "string",
"unique": true
},
"image": {
"allowedTypes": [
"images",
"files",
"videos",
"audios"
],
"type": "media",
"multiple": false
},
"subtitle": {
"type": "string"
}
}
}
7 changes: 7 additions & 0 deletions src/api/subcategory/controllers/subcategory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* subcategory controller
*/

import { factories } from '@strapi/strapi'

export default factories.createCoreController('api::subcategory.subcategory');
7 changes: 7 additions & 0 deletions src/api/subcategory/routes/subcategory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* subcategory router
*/

import { factories } from '@strapi/strapi';

export default factories.createCoreRouter('api::subcategory.subcategory');
7 changes: 7 additions & 0 deletions src/api/subcategory/services/subcategory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* subcategory service
*/

import { factories } from '@strapi/strapi';

export default factories.createCoreService('api::subcategory.subcategory');
18 changes: 18 additions & 0 deletions src/components/categories/subcategories.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"collectionName": "components_categories_subcategories",
"info": {
"displayName": "subcategories"
},
"options": {},
"attributes": {
"name": {
"type": "string"
},
"slug": {
"type": "string"
},
"subtitle": {
"type": "string"
}
}
}
13 changes: 13 additions & 0 deletions types/generated/components.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import type { Schema, Struct } from '@strapi/strapi';

export interface CategoriesSubcategories extends Struct.ComponentSchema {
collectionName: 'components_categories_subcategories';
info: {
displayName: 'subcategories';
};
attributes: {
name: Schema.Attribute.String;
slug: Schema.Attribute.String;
subtitle: Schema.Attribute.String;
};
}

export interface CommonButton extends Struct.ComponentSchema {
collectionName: 'components_common_buttons';
info: {
Expand Down Expand Up @@ -40,6 +52,7 @@ export interface CommonLink extends Struct.ComponentSchema {
declare module '@strapi/strapi' {
export module Public {
export interface ComponentSchemas {
'categories.subcategories': CategoriesSubcategories;
'common.button': CommonButton;
'common.image': CommonImage;
'common.link': CommonLink;
Expand Down
45 changes: 45 additions & 0 deletions types/generated/contentTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ export interface AdminUser extends Struct.CollectionTypeSchema {
export interface ApiCategoryCategory extends Struct.CollectionTypeSchema {
collectionName: 'categories';
info: {
description: '';
displayName: 'Categories';
pluralName: 'categories';
singularName: 'category';
Expand All @@ -388,6 +389,12 @@ export interface ApiCategoryCategory extends Struct.CollectionTypeSchema {
createdAt: Schema.Attribute.DateTime;
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
image: Schema.Attribute.Media<'images' | 'files' | 'videos' | 'audios'> &
Schema.Attribute.SetPluginOptions<{
i18n: {
localized: true;
};
}>;
locale: Schema.Attribute.String;
localizations: Schema.Attribute.Relation<
'oneToMany',
Expand All @@ -408,6 +415,12 @@ export interface ApiCategoryCategory extends Struct.CollectionTypeSchema {
localized: false;
};
}>;
subtitle: Schema.Attribute.String &
Schema.Attribute.SetPluginOptions<{
i18n: {
localized: true;
};
}>;
updatedAt: Schema.Attribute.DateTime;
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
Expand Down Expand Up @@ -527,6 +540,37 @@ export interface ApiNavbarNavbar extends Struct.SingleTypeSchema {
};
}

export interface ApiSubcategorySubcategory extends Struct.CollectionTypeSchema {
collectionName: 'subcategories';
info: {
displayName: 'subcategories';
pluralName: 'subcategories';
singularName: 'subcategory';
};
options: {
draftAndPublish: true;
};
attributes: {
createdAt: Schema.Attribute.DateTime;
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
image: Schema.Attribute.Media<'images' | 'files' | 'videos' | 'audios'>;
locale: Schema.Attribute.String & Schema.Attribute.Private;
localizations: Schema.Attribute.Relation<
'oneToMany',
'api::subcategory.subcategory'
> &
Schema.Attribute.Private;
name: Schema.Attribute.String;
publishedAt: Schema.Attribute.DateTime;
slug: Schema.Attribute.String & Schema.Attribute.Unique;
subtitle: Schema.Attribute.String;
updatedAt: Schema.Attribute.DateTime;
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
};
}

export interface PluginContentReleasesRelease
extends Struct.CollectionTypeSchema {
collectionName: 'strapi_releases';
Expand Down Expand Up @@ -1039,6 +1083,7 @@ declare module '@strapi/strapi' {
'api::category.category': ApiCategoryCategory;
'api::landing-page.landing-page': ApiLandingPageLandingPage;
'api::navbar.navbar': ApiNavbarNavbar;
'api::subcategory.subcategory': ApiSubcategorySubcategory;
'plugin::content-releases.release': PluginContentReleasesRelease;
'plugin::content-releases.release-action': PluginContentReleasesReleaseAction;
'plugin::i18n.locale': PluginI18NLocale;
Expand Down

0 comments on commit a45a1d1

Please sign in to comment.