From 64e3207ffb5c73f47aa884801e932b9a24e26a5b Mon Sep 17 00:00:00 2001 From: nicwands Date: Tue, 9 Jun 2026 14:42:57 -0400 Subject: [PATCH] move mosaic items to collection type --- src/api/home/content-types/home/schema.json | 6 +-- .../content-types/mosaic-item/schema.json | 41 +++++++++++++++++++ .../mosaic-item/controllers/mosaic-item.ts | 7 ++++ src/api/mosaic-item/routes/mosaic-item.ts | 7 ++++ src/api/mosaic-item/services/mosaic-item.ts | 7 ++++ src/components/global/copy.json | 14 +++++++ src/components/global/media.json | 26 ++++++++++++ src/components/global/mosaic-item.json | 29 ------------- types/generated/components.d.ts | 28 +++++++++---- types/generated/contentTypes.d.ts | 38 ++++++++++++++++- 10 files changed, 161 insertions(+), 42 deletions(-) create mode 100644 src/api/mosaic-item/content-types/mosaic-item/schema.json create mode 100644 src/api/mosaic-item/controllers/mosaic-item.ts create mode 100644 src/api/mosaic-item/routes/mosaic-item.ts create mode 100644 src/api/mosaic-item/services/mosaic-item.ts create mode 100644 src/components/global/copy.json create mode 100644 src/components/global/media.json delete mode 100644 src/components/global/mosaic-item.json diff --git a/src/api/home/content-types/home/schema.json b/src/api/home/content-types/home/schema.json index ef8b4cb..cee63e8 100644 --- a/src/api/home/content-types/home/schema.json +++ b/src/api/home/content-types/home/schema.json @@ -12,9 +12,9 @@ "pluginOptions": {}, "attributes": { "mosaic_items": { - "type": "component", - "component": "global.mosaic-item", - "repeatable": true + "type": "relation", + "relation": "oneToMany", + "target": "api::mosaic-item.mosaic-item" } } } diff --git a/src/api/mosaic-item/content-types/mosaic-item/schema.json b/src/api/mosaic-item/content-types/mosaic-item/schema.json new file mode 100644 index 0000000..9d50830 --- /dev/null +++ b/src/api/mosaic-item/content-types/mosaic-item/schema.json @@ -0,0 +1,41 @@ +{ + "kind": "collectionType", + "collectionName": "mosaic_items", + "info": { + "singularName": "mosaic-item", + "pluralName": "mosaic-items", + "displayName": "Mosaic Item" + }, + "options": { + "draftAndPublish": true + }, + "pluginOptions": {}, + "attributes": { + "slug": { + "type": "uid", + "targetField": "title" + }, + "title": { + "type": "string" + }, + "image": { + "type": "media", + "multiple": false, + "allowedTypes": [ + "images" + ] + }, + "dl": { + "type": "component", + "component": "global.descriptive-list", + "repeatable": true + }, + "content": { + "type": "dynamiczone", + "components": [ + "global.copy", + "global.media" + ] + } + } +} diff --git a/src/api/mosaic-item/controllers/mosaic-item.ts b/src/api/mosaic-item/controllers/mosaic-item.ts new file mode 100644 index 0000000..c4eec38 --- /dev/null +++ b/src/api/mosaic-item/controllers/mosaic-item.ts @@ -0,0 +1,7 @@ +/** + * mosaic-item controller + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreController('api::mosaic-item.mosaic-item'); diff --git a/src/api/mosaic-item/routes/mosaic-item.ts b/src/api/mosaic-item/routes/mosaic-item.ts new file mode 100644 index 0000000..c0c6a37 --- /dev/null +++ b/src/api/mosaic-item/routes/mosaic-item.ts @@ -0,0 +1,7 @@ +/** + * mosaic-item router + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreRouter('api::mosaic-item.mosaic-item'); diff --git a/src/api/mosaic-item/services/mosaic-item.ts b/src/api/mosaic-item/services/mosaic-item.ts new file mode 100644 index 0000000..f6b1a98 --- /dev/null +++ b/src/api/mosaic-item/services/mosaic-item.ts @@ -0,0 +1,7 @@ +/** + * mosaic-item service + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreService('api::mosaic-item.mosaic-item'); diff --git a/src/components/global/copy.json b/src/components/global/copy.json new file mode 100644 index 0000000..73a2f29 --- /dev/null +++ b/src/components/global/copy.json @@ -0,0 +1,14 @@ +{ + "collectionName": "components_global_copies", + "info": { + "displayName": "Copy", + "icon": "bold" + }, + "options": {}, + "attributes": { + "content": { + "type": "blocks" + } + }, + "config": {} +} diff --git a/src/components/global/media.json b/src/components/global/media.json new file mode 100644 index 0000000..ba73ade --- /dev/null +++ b/src/components/global/media.json @@ -0,0 +1,26 @@ +{ + "collectionName": "components_global_media", + "info": { + "displayName": "Media", + "icon": "landscape" + }, + "options": {}, + "attributes": { + "image": { + "type": "media", + "multiple": false, + "required": true, + "allowedTypes": [ + "images" + ] + }, + "video": { + "type": "media", + "multiple": false, + "allowedTypes": [ + "videos" + ] + } + }, + "config": {} +} diff --git a/src/components/global/mosaic-item.json b/src/components/global/mosaic-item.json deleted file mode 100644 index 7cd3669..0000000 --- a/src/components/global/mosaic-item.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "collectionName": "components_global_mosaic_items", - "info": { - "displayName": "Mosaic Item", - "icon": "apps" - }, - "options": {}, - "attributes": { - "image": { - "type": "media", - "multiple": false, - "allowedTypes": [ - "images" - ] - }, - "title": { - "type": "string" - }, - "dl": { - "type": "component", - "component": "global.descriptive-list", - "repeatable": true - }, - "content": { - "type": "blocks" - } - }, - "config": {} -} diff --git a/types/generated/components.d.ts b/types/generated/components.d.ts index 78e80d4..b18b5a8 100644 --- a/types/generated/components.d.ts +++ b/types/generated/components.d.ts @@ -1,5 +1,16 @@ import type { Schema, Struct } from '@strapi/strapi'; +export interface GlobalCopy extends Struct.ComponentSchema { + collectionName: 'components_global_copies'; + info: { + displayName: 'Copy'; + icon: 'bold'; + }; + attributes: { + content: Schema.Attribute.Blocks; + }; +} + export interface GlobalDescriptiveList extends Struct.ComponentSchema { collectionName: 'components_global_descriptive_lists'; info: { @@ -12,17 +23,15 @@ export interface GlobalDescriptiveList extends Struct.ComponentSchema { }; } -export interface GlobalMosaicItem extends Struct.ComponentSchema { - collectionName: 'components_global_mosaic_items'; +export interface GlobalMedia extends Struct.ComponentSchema { + collectionName: 'components_global_media'; info: { - displayName: 'Mosaic Item'; - icon: 'apps'; + displayName: 'Media'; + icon: 'landscape'; }; attributes: { - content: Schema.Attribute.Blocks; - dl: Schema.Attribute.Component<'global.descriptive-list', true>; - image: Schema.Attribute.Media<'images'>; - title: Schema.Attribute.String; + image: Schema.Attribute.Media<'images'> & Schema.Attribute.Required; + video: Schema.Attribute.Media<'videos'>; }; } @@ -42,8 +51,9 @@ export interface GlobalSeo extends Struct.ComponentSchema { declare module '@strapi/strapi' { export module Public { export interface ComponentSchemas { + 'global.copy': GlobalCopy; 'global.descriptive-list': GlobalDescriptiveList; - 'global.mosaic-item': GlobalMosaicItem; + 'global.media': GlobalMedia; 'global.seo': GlobalSeo; } } diff --git a/types/generated/contentTypes.d.ts b/types/generated/contentTypes.d.ts index c1d2990..771a547 100644 --- a/types/generated/contentTypes.d.ts +++ b/types/generated/contentTypes.d.ts @@ -487,7 +487,10 @@ export interface ApiHomeHome extends Struct.SingleTypeSchema { locale: Schema.Attribute.String & Schema.Attribute.Private; localizations: Schema.Attribute.Relation<'oneToMany', 'api::home.home'> & Schema.Attribute.Private; - mosaic_items: Schema.Attribute.Component<'global.mosaic-item', true>; + mosaic_items: Schema.Attribute.Relation< + 'oneToMany', + 'api::mosaic-item.mosaic-item' + >; publishedAt: Schema.Attribute.DateTime; updatedAt: Schema.Attribute.DateTime; updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> & @@ -495,6 +498,38 @@ export interface ApiHomeHome extends Struct.SingleTypeSchema { }; } +export interface ApiMosaicItemMosaicItem extends Struct.CollectionTypeSchema { + collectionName: 'mosaic_items'; + info: { + displayName: 'Mosaic Item'; + pluralName: 'mosaic-items'; + singularName: 'mosaic-item'; + }; + options: { + draftAndPublish: true; + }; + attributes: { + content: Schema.Attribute.DynamicZone<['global.copy', 'global.media']>; + createdAt: Schema.Attribute.DateTime; + createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> & + Schema.Attribute.Private; + dl: Schema.Attribute.Component<'global.descriptive-list', true>; + image: Schema.Attribute.Media<'images'>; + locale: Schema.Attribute.String & Schema.Attribute.Private; + localizations: Schema.Attribute.Relation< + 'oneToMany', + 'api::mosaic-item.mosaic-item' + > & + Schema.Attribute.Private; + publishedAt: Schema.Attribute.DateTime; + slug: Schema.Attribute.UID<'title'>; + title: 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'; @@ -1008,6 +1043,7 @@ declare module '@strapi/strapi' { 'admin::user': AdminUser; 'api::global.global': ApiGlobalGlobal; 'api::home.home': ApiHomeHome; + 'api::mosaic-item.mosaic-item': ApiMosaicItemMosaicItem; 'plugin::content-releases.release': PluginContentReleasesRelease; 'plugin::content-releases.release-action': PluginContentReleasesReleaseAction; 'plugin::i18n.locale': PluginI18NLocale;