feat: add missing fields

This commit is contained in:
Hossein Mehrabi 2024-01-18 02:01:44 +03:30
parent 0e8b912b37
commit 1e713853c4
No known key found for this signature in database
GPG Key ID: 45C04964191AFAA1
9 changed files with 155 additions and 7 deletions

View File

@ -0,0 +1,37 @@
{
"kind": "collectionType",
"collectionName": "pages",
"info": {
"singularName": "page",
"pluralName": "pages",
"displayName": "Page",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"title": {
"type": "string"
},
"slug": {
"type": "uid",
"targetField": "title"
},
"body": {
"type": "customField",
"options": {
"output": "HTML",
"preset": "standard"
},
"customField": "plugin::ckeditor.CKEditor"
},
"subtitle": {
"type": "string"
},
"description": {
"type": "text"
}
}
}

View File

@ -0,0 +1,7 @@
/**
* page controller
*/
import { factories } from '@strapi/strapi'
export default factories.createCoreController('api::page.page');

View File

@ -0,0 +1,7 @@
/**
* page router
*/
import { factories } from '@strapi/strapi';
export default factories.createCoreRouter('api::page.page');

View File

@ -0,0 +1,7 @@
/**
* page service
*/
import { factories } from '@strapi/strapi';
export default factories.createCoreService('api::page.page');

View File

@ -12,7 +12,7 @@
},
"pluginOptions": {},
"attributes": {
"Name": {
"name": {
"type": "string",
"required": true
},
@ -33,13 +33,19 @@
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": ["images"]
"allowedTypes": [
"images"
]
},
"posts": {
"type": "relation",
"relation": "oneToMany",
"target": "api::post.post",
"mappedBy": "podcast_show"
},
"slug": {
"type": "uid",
"targetField": "name"
}
}
}

View File

@ -27,7 +27,10 @@
},
"type": {
"type": "enumeration",
"enum": ["Article", "Episode"],
"enum": [
"Article",
"Episode"
],
"default": "Article"
},
"episode_number": {
@ -64,7 +67,9 @@
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": ["images"]
"allowedTypes": [
"images"
]
},
"tags": {
"type": "relation",
@ -85,6 +90,16 @@
"preset": "standard"
},
"customField": "plugin::ckeditor.CKEditor"
},
"featured": {
"type": "boolean",
"default": false,
"required": false
},
"related_posts": {
"type": "relation",
"relation": "oneToMany",
"target": "api::post.post"
}
}
}

View File

@ -2,6 +2,21 @@
* tag controller
*/
import { factories } from '@strapi/strapi'
import { factories } from "@strapi/strapi";
export default factories.createCoreController('api::tag.tag');
export default factories.createCoreController("api::tag.tag", ({ strapi }) => ({
async getAll(ctx) {
const tags = await strapi.entityService.findMany("api::tag.tag", {
populate: {
posts: {
count: true,
} as any,
},
fields: "id,name",
limit: 1000,
sort: "name:asc",
});
return tags;
},
}));

View File

@ -0,0 +1,12 @@
export default {
routes: [
{
method: "GET",
path: "/tags/getAll",
handler: "tag.getAll",
config: {
policies: [],
},
},
],
};

View File

@ -800,6 +800,40 @@ export interface ApiAuthorAuthor extends Schema.CollectionType {
};
}
export interface ApiPagePage extends Schema.CollectionType {
collectionName: 'pages';
info: {
singularName: 'page';
pluralName: 'pages';
displayName: 'Page';
description: '';
};
options: {
draftAndPublish: true;
};
attributes: {
title: Attribute.String;
slug: Attribute.UID<'api::page.page', 'title'>;
body: Attribute.RichText &
Attribute.CustomField<
'plugin::ckeditor.CKEditor',
{
output: 'HTML';
preset: 'standard';
}
>;
subtitle: Attribute.String;
description: Attribute.Text;
createdAt: Attribute.DateTime;
updatedAt: Attribute.DateTime;
publishedAt: Attribute.DateTime;
createdBy: Attribute.Relation<'api::page.page', 'oneToOne', 'admin::user'> &
Attribute.Private;
updatedBy: Attribute.Relation<'api::page.page', 'oneToOne', 'admin::user'> &
Attribute.Private;
};
}
export interface ApiPodcastShowPodcastShow extends Schema.CollectionType {
collectionName: 'podcast_shows';
info: {
@ -812,7 +846,7 @@ export interface ApiPodcastShowPodcastShow extends Schema.CollectionType {
draftAndPublish: true;
};
attributes: {
Name: Attribute.String & Attribute.Required;
name: Attribute.String & Attribute.Required;
hosts: Attribute.Relation<
'api::podcast-show.podcast-show',
'oneToMany',
@ -832,6 +866,7 @@ export interface ApiPodcastShowPodcastShow extends Schema.CollectionType {
'oneToMany',
'api::post.post'
>;
slug: Attribute.UID<'api::podcast-show.podcast-show', 'name'>;
createdAt: Attribute.DateTime;
updatedAt: Attribute.DateTime;
publishedAt: Attribute.DateTime;
@ -906,6 +941,12 @@ export interface ApiPostPost extends Schema.CollectionType {
preset: 'standard';
}
>;
featured: Attribute.Boolean & Attribute.DefaultTo<false>;
related_posts: Attribute.Relation<
'api::post.post',
'oneToMany',
'api::post.post'
>;
createdAt: Attribute.DateTime;
updatedAt: Attribute.DateTime;
publishedAt: Attribute.DateTime;
@ -958,6 +999,7 @@ declare module '@strapi/types' {
'plugin::users-permissions.role': PluginUsersPermissionsRole;
'plugin::users-permissions.user': PluginUsersPermissionsUser;
'api::author.author': ApiAuthorAuthor;
'api::page.page': ApiPagePage;
'api::podcast-show.podcast-show': ApiPodcastShowPodcastShow;
'api::post.post': ApiPostPost;
'api::tag.tag': ApiTagTag;