Skip to content

Commit 9c73d08

Browse files
committed
feat: add blogs, author and categories collection type
1 parent ee0ef64 commit 9c73d08

File tree

7 files changed

+99
-12
lines changed

7 files changed

+99
-12
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"kind": "collectionType",
3+
"collectionName": "authors",
4+
"info": {
5+
"singularName": "author",
6+
"pluralName": "authors",
7+
"displayName": "Author"
8+
},
9+
"options": {
10+
"draftAndPublish": true
11+
},
12+
"pluginOptions": {},
13+
"attributes": {
14+
"author": {
15+
"type": "string"
16+
},
17+
"blogs": {
18+
"type": "relation",
19+
"relation": "manyToMany",
20+
"target": "api::blog-page.blog-page",
21+
"mappedBy": "authors"
22+
}
23+
}
24+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* author controller
3+
*/
4+
5+
import { factories } from '@strapi/strapi'
6+
7+
export default factories.createCoreController('api::author.author');

src/api/author/routes/author.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* author router
3+
*/
4+
5+
import { factories } from '@strapi/strapi';
6+
7+
export default factories.createCoreRouter('api::author.author');

src/api/author/services/author.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* author service
3+
*/
4+
5+
import { factories } from '@strapi/strapi';
6+
7+
export default factories.createCoreService('api::author.author');

src/api/blog-page/content-types/blog-page/schema.json

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"image": {
2828
"type": "media",
2929
"multiple": false,
30-
"required": true,
30+
"required": false,
3131
"allowedTypes": [
3232
"images",
3333
"files",
@@ -49,9 +49,22 @@
4949
},
5050
"catogaries": {
5151
"type": "relation",
52-
"relation": "oneToMany",
52+
"relation": "manyToMany",
5353
"target": "api::catogary.catogary",
54-
"mappedBy": "catogary"
54+
"mappedBy": "blogs"
55+
},
56+
"caseStudies": {
57+
"type": "boolean",
58+
"default": false
59+
},
60+
"authors": {
61+
"type": "relation",
62+
"relation": "manyToMany",
63+
"target": "api::author.author",
64+
"inversedBy": "blogs"
65+
},
66+
"seoDescription": {
67+
"type": "text"
5568
}
5669
}
5770
}

src/api/catogary/content-types/catogary/schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
"category": {
1515
"type": "string"
1616
},
17-
"catogary": {
17+
"blogs": {
1818
"type": "relation",
19-
"relation": "manyToOne",
19+
"relation": "manyToMany",
2020
"target": "api::blog-page.blog-page",
2121
"inversedBy": "catogaries"
2222
}

types/generated/contentTypes.d.ts

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,35 @@ export interface ApiAboutUsAboutUs extends Struct.SingleTypeSchema {
409409
};
410410
}
411411

412+
export interface ApiAuthorAuthor extends Struct.CollectionTypeSchema {
413+
collectionName: 'authors';
414+
info: {
415+
displayName: 'Author';
416+
pluralName: 'authors';
417+
singularName: 'author';
418+
};
419+
options: {
420+
draftAndPublish: true;
421+
};
422+
attributes: {
423+
author: Schema.Attribute.String;
424+
blogs: Schema.Attribute.Relation<'manyToMany', 'api::blog-page.blog-page'>;
425+
createdAt: Schema.Attribute.DateTime;
426+
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
427+
Schema.Attribute.Private;
428+
locale: Schema.Attribute.String & Schema.Attribute.Private;
429+
localizations: Schema.Attribute.Relation<
430+
'oneToMany',
431+
'api::author.author'
432+
> &
433+
Schema.Attribute.Private;
434+
publishedAt: Schema.Attribute.DateTime;
435+
updatedAt: Schema.Attribute.DateTime;
436+
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
437+
Schema.Attribute.Private;
438+
};
439+
}
440+
412441
export interface ApiBlogPageBlogPage extends Struct.CollectionTypeSchema {
413442
collectionName: 'blog_pages';
414443
info: {
@@ -421,17 +450,18 @@ export interface ApiBlogPageBlogPage extends Struct.CollectionTypeSchema {
421450
draftAndPublish: true;
422451
};
423452
attributes: {
453+
authors: Schema.Attribute.Relation<'manyToMany', 'api::author.author'>;
454+
caseStudies: Schema.Attribute.Boolean & Schema.Attribute.DefaultTo<false>;
424455
catogaries: Schema.Attribute.Relation<
425-
'oneToMany',
456+
'manyToMany',
426457
'api::catogary.catogary'
427458
>;
428459
content: Schema.Attribute.RichText & Schema.Attribute.Required;
429460
createdAt: Schema.Attribute.DateTime;
430461
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
431462
Schema.Attribute.Private;
432463
description: Schema.Attribute.Text & Schema.Attribute.Required;
433-
image: Schema.Attribute.Media<'images' | 'files' | 'videos' | 'audios'> &
434-
Schema.Attribute.Required;
464+
image: Schema.Attribute.Media<'images' | 'files' | 'videos' | 'audios'>;
435465
locale: Schema.Attribute.String & Schema.Attribute.Private;
436466
localizations: Schema.Attribute.Relation<
437467
'oneToMany',
@@ -440,6 +470,7 @@ export interface ApiBlogPageBlogPage extends Struct.CollectionTypeSchema {
440470
Schema.Attribute.Private;
441471
publishDate: Schema.Attribute.Date & Schema.Attribute.Required;
442472
publishedAt: Schema.Attribute.DateTime;
473+
seoDescription: Schema.Attribute.Text;
443474
seoTitle: Schema.Attribute.String & Schema.Attribute.Required;
444475
slug: Schema.Attribute.String & Schema.Attribute.Required;
445476
title: Schema.Attribute.String & Schema.Attribute.Required;
@@ -488,11 +519,8 @@ export interface ApiCatogaryCatogary extends Struct.CollectionTypeSchema {
488519
draftAndPublish: true;
489520
};
490521
attributes: {
522+
blogs: Schema.Attribute.Relation<'manyToMany', 'api::blog-page.blog-page'>;
491523
category: Schema.Attribute.String;
492-
catogary: Schema.Attribute.Relation<
493-
'manyToOne',
494-
'api::blog-page.blog-page'
495-
>;
496524
createdAt: Schema.Attribute.DateTime;
497525
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
498526
Schema.Attribute.Private;
@@ -1590,6 +1618,7 @@ declare module '@strapi/strapi' {
15901618
'admin::transfer-token-permission': AdminTransferTokenPermission;
15911619
'admin::user': AdminUser;
15921620
'api::about-us.about-us': ApiAboutUsAboutUs;
1621+
'api::author.author': ApiAuthorAuthor;
15931622
'api::blog-page.blog-page': ApiBlogPageBlogPage;
15941623
'api::blog.blog': ApiBlogBlog;
15951624
'api::catogary.catogary': ApiCatogaryCatogary;

0 commit comments

Comments
 (0)