diff --git a/src/api/blog-collection/content-types/blog-collection/schema.json b/src/api/blog-collection/content-types/blog-collection/schema.json new file mode 100644 index 0000000..65dda29 --- /dev/null +++ b/src/api/blog-collection/content-types/blog-collection/schema.json @@ -0,0 +1,45 @@ +{ + "kind": "collectionType", + "collectionName": "blog_collections", + "info": { + "singularName": "blog-collection", + "pluralName": "blog-collections", + "displayName": "Blog Collection", + "description": "" + }, + "options": { + "draftAndPublish": true + }, + "pluginOptions": {}, + "attributes": { + "name": { + "type": "string", + "required": true, + "unique": true + }, + "slug": { + "type": "uid", + "targetField": "name" + }, + "picture": { + "type": "media", + "multiple": false, + "required": false, + "allowedTypes": [ + "images", + "files", + "videos", + "audios" + ] + }, + "description": { + "type": "text" + }, + "posts": { + "type": "relation", + "relation": "oneToMany", + "target": "api::blog-post.blog-post", + "mappedBy": "collection" + } + } +} diff --git a/src/api/blog-collection/controllers/blog-collection.js b/src/api/blog-collection/controllers/blog-collection.js new file mode 100644 index 0000000..b8865ba --- /dev/null +++ b/src/api/blog-collection/controllers/blog-collection.js @@ -0,0 +1,9 @@ +'use strict'; + +/** + * blog-collection controller + */ + +const { createCoreController } = require('@strapi/strapi').factories; + +module.exports = createCoreController('api::blog-collection.blog-collection'); diff --git a/src/api/blog-collection/routes/blog-collection.js b/src/api/blog-collection/routes/blog-collection.js new file mode 100644 index 0000000..d9f7ab9 --- /dev/null +++ b/src/api/blog-collection/routes/blog-collection.js @@ -0,0 +1,9 @@ +'use strict'; + +/** + * blog-collection router + */ + +const { createCoreRouter } = require('@strapi/strapi').factories; + +module.exports = createCoreRouter('api::blog-collection.blog-collection'); diff --git a/src/api/blog-collection/services/blog-collection.js b/src/api/blog-collection/services/blog-collection.js new file mode 100644 index 0000000..5947022 --- /dev/null +++ b/src/api/blog-collection/services/blog-collection.js @@ -0,0 +1,9 @@ +'use strict'; + +/** + * blog-collection service + */ + +const { createCoreService } = require('@strapi/strapi').factories; + +module.exports = createCoreService('api::blog-collection.blog-collection'); diff --git a/src/api/blog-post/content-types/blog-post/schema.json b/src/api/blog-post/content-types/blog-post/schema.json index fc83915..8359650 100644 --- a/src/api/blog-post/content-types/blog-post/schema.json +++ b/src/api/blog-post/content-types/blog-post/schema.json @@ -38,6 +38,12 @@ "type": "relation", "relation": "oneToMany", "target": "api::tag.tag" + }, + "collection": { + "type": "relation", + "relation": "manyToOne", + "target": "api::blog-collection.blog-collection", + "inversedBy": "posts" } } } diff --git a/src/api/tag/content-types/tag/schema.json b/src/api/tag/content-types/tag/schema.json index b26109d..5579012 100644 --- a/src/api/tag/content-types/tag/schema.json +++ b/src/api/tag/content-types/tag/schema.json @@ -4,7 +4,8 @@ "info": { "singularName": "tag", "pluralName": "tags", - "displayName": "Tag" + "displayName": "Tag", + "description": "" }, "options": { "draftAndPublish": true @@ -12,7 +13,8 @@ "pluginOptions": {}, "attributes": { "name": { - "type": "string" + "type": "string", + "required": true }, "slug": { "type": "uid", diff --git a/types/generated/contentTypes.d.ts b/types/generated/contentTypes.d.ts index bdb73b5..f17a67d 100644 --- a/types/generated/contentTypes.d.ts +++ b/types/generated/contentTypes.d.ts @@ -863,6 +863,45 @@ export interface ApiAuthorAuthor extends Schema.CollectionType { }; } +export interface ApiBlogCollectionBlogCollection extends Schema.CollectionType { + collectionName: 'blog_collections'; + info: { + singularName: 'blog-collection'; + pluralName: 'blog-collections'; + displayName: 'Blog Collection'; + description: ''; + }; + options: { + draftAndPublish: true; + }; + attributes: { + name: Attribute.String & Attribute.Required & Attribute.Unique; + slug: Attribute.UID<'api::blog-collection.blog-collection', 'name'>; + picture: Attribute.Media<'images' | 'files' | 'videos' | 'audios'>; + description: Attribute.Text; + posts: Attribute.Relation< + 'api::blog-collection.blog-collection', + 'oneToMany', + 'api::blog-post.blog-post' + >; + createdAt: Attribute.DateTime; + updatedAt: Attribute.DateTime; + publishedAt: Attribute.DateTime; + createdBy: Attribute.Relation< + 'api::blog-collection.blog-collection', + 'oneToOne', + 'admin::user' + > & + Attribute.Private; + updatedBy: Attribute.Relation< + 'api::blog-collection.blog-collection', + 'oneToOne', + 'admin::user' + > & + Attribute.Private; + }; +} + export interface ApiBlogPostBlogPost extends Schema.CollectionType { collectionName: 'blog_posts'; info: { @@ -891,6 +930,11 @@ export interface ApiBlogPostBlogPost extends Schema.CollectionType { 'oneToMany', 'api::tag.tag' >; + collection: Attribute.Relation< + 'api::blog-post.blog-post', + 'manyToOne', + 'api::blog-collection.blog-collection' + >; createdAt: Attribute.DateTime; updatedAt: Attribute.DateTime; publishedAt: Attribute.DateTime; @@ -915,12 +959,13 @@ export interface ApiTagTag extends Schema.CollectionType { singularName: 'tag'; pluralName: 'tags'; displayName: 'Tag'; + description: ''; }; options: { draftAndPublish: true; }; attributes: { - name: Attribute.String; + name: Attribute.String & Attribute.Required; slug: Attribute.UID<'api::tag.tag', 'name'>; createdAt: Attribute.DateTime; updatedAt: Attribute.DateTime; @@ -952,6 +997,7 @@ declare module '@strapi/types' { 'plugin::users-permissions.user': PluginUsersPermissionsUser; 'plugin::slugify.slug': PluginSlugifySlug; 'api::author.author': ApiAuthorAuthor; + 'api::blog-collection.blog-collection': ApiBlogCollectionBlogCollection; 'api::blog-post.blog-post': ApiBlogPostBlogPost; 'api::tag.tag': ApiTagTag; }