Skip to content

Commit 55bcba0

Browse files
committed
feat: introduce city content type and add url alias and city relations to category.
1 parent 838ac14 commit 55bcba0

File tree

6 files changed

+111
-2
lines changed

6 files changed

+111
-2
lines changed

playground/src/api/category/content-types/category/schema.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,19 @@
2323
"inversedBy": "category"
2424
},
2525
"title": {
26-
"type": "string",
27-
"pluginOptions": {}
26+
"type": "string"
27+
},
28+
"url_alias": {
29+
"type": "relation",
30+
"relation": "oneToMany",
31+
"target": "plugin::webtools.url-alias",
32+
"configurable": false
33+
},
34+
"cities": {
35+
"type": "relation",
36+
"relation": "manyToMany",
37+
"target": "api::city.city",
38+
"mappedBy": "categories"
2839
}
2940
}
3041
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"kind": "collectionType",
3+
"collectionName": "cities",
4+
"info": {
5+
"singularName": "city",
6+
"pluralName": "cities",
7+
"displayName": "City"
8+
},
9+
"options": {
10+
"draftAndPublish": true
11+
},
12+
"pluginOptions": {
13+
"webtools": {
14+
"enabled": true
15+
}
16+
},
17+
"attributes": {
18+
"title": {
19+
"type": "string"
20+
},
21+
"categories": {
22+
"type": "relation",
23+
"relation": "manyToMany",
24+
"target": "api::category.category",
25+
"inversedBy": "cities"
26+
},
27+
"slug": {
28+
"type": "uid",
29+
"targetField": "title"
30+
}
31+
}
32+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* city controller
3+
*/
4+
5+
import { factories } from '@strapi/strapi';
6+
7+
export default factories.createCoreController('api::city.city');
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* city router
3+
*/
4+
5+
import { factories } from '@strapi/strapi';
6+
7+
export default factories.createCoreRouter('api::city.city');
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* city service
3+
*/
4+
5+
import { factories } from '@strapi/strapi';
6+
7+
export default factories.createCoreService('api::city.city');

playground/types/generated/contentTypes.d.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ export interface ApiCategoryCategory extends Struct.CollectionTypeSchema {
447447
};
448448
};
449449
attributes: {
450+
cities: Schema.Attribute.Relation<'manyToMany', 'api::city.city'>;
450451
createdAt: Schema.Attribute.DateTime;
451452
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
452453
Schema.Attribute.Private;
@@ -473,6 +474,49 @@ export interface ApiCategoryCategory extends Struct.CollectionTypeSchema {
473474
};
474475
}
475476

477+
export interface ApiCityCity extends Struct.CollectionTypeSchema {
478+
collectionName: 'cities';
479+
info: {
480+
displayName: 'City';
481+
pluralName: 'cities';
482+
singularName: 'city';
483+
};
484+
options: {
485+
draftAndPublish: true;
486+
};
487+
pluginOptions: {
488+
webtools: {
489+
enabled: true;
490+
};
491+
};
492+
attributes: {
493+
categories: Schema.Attribute.Relation<
494+
'manyToMany',
495+
'api::category.category'
496+
>;
497+
createdAt: Schema.Attribute.DateTime;
498+
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
499+
Schema.Attribute.Private;
500+
locale: Schema.Attribute.String & Schema.Attribute.Private;
501+
localizations: Schema.Attribute.Relation<'oneToMany', 'api::city.city'> &
502+
Schema.Attribute.Private;
503+
publishedAt: Schema.Attribute.DateTime;
504+
sitemap_exclude: Schema.Attribute.Boolean &
505+
Schema.Attribute.Private &
506+
Schema.Attribute.DefaultTo<false>;
507+
slug: Schema.Attribute.UID<'title'>;
508+
title: Schema.Attribute.String;
509+
updatedAt: Schema.Attribute.DateTime;
510+
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
511+
Schema.Attribute.Private;
512+
url_alias: Schema.Attribute.Relation<
513+
'oneToMany',
514+
'plugin::webtools.url-alias'
515+
> &
516+
Schema.Attribute.Unique;
517+
};
518+
}
519+
476520
export interface ApiHomeHome extends Struct.SingleTypeSchema {
477521
collectionName: 'homes';
478522
info: {
@@ -1259,6 +1303,7 @@ declare module '@strapi/strapi' {
12591303
'admin::transfer-token-permission': AdminTransferTokenPermission;
12601304
'admin::user': AdminUser;
12611305
'api::category.category': ApiCategoryCategory;
1306+
'api::city.city': ApiCityCity;
12621307
'api::home.home': ApiHomeHome;
12631308
'api::private-category.private-category': ApiPrivateCategoryPrivateCategory;
12641309
'api::test.test': ApiTestTest;

0 commit comments

Comments
 (0)