From 00eb7e2e63f80af142b53d3bb9b91272fcdd8185 Mon Sep 17 00:00:00 2001 From: Navin Moorthy Date: Mon, 22 May 2023 10:20:24 +0530 Subject: [PATCH] =?UTF-8?q?feat(footer-api):=20=E2=9C=A8=20Add=20link=20co?= =?UTF-8?q?mponents=20to=20footer=20content=20type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- http/api.http | 2 +- schemas.d.ts | 65 ++++++++++++------- .../footer/content-types/footer/schema.json | 7 +- src/components/website/link.json | 25 +++++++ 4 files changed, 72 insertions(+), 27 deletions(-) create mode 100644 src/components/website/link.json diff --git a/http/api.http b/http/api.http index 5365576..656d05f 100644 --- a/http/api.http +++ b/http/api.http @@ -5,5 +5,5 @@ ### # Get the footer contents -GET {{baseURL}}/api/footer +GET {{baseURL}}/api/footer?populate=* Authorization: Bearer {{$dotenv API_TOKEN}} diff --git a/schemas.d.ts b/schemas.d.ts index 7b3e69f..570bf44 100644 --- a/schemas.d.ts +++ b/schemas.d.ts @@ -2,6 +2,8 @@ import { BigIntegerAttribute, BooleanAttribute, CollectionTypeSchema, + ComponentAttribute, + ComponentSchema, DateTimeAttribute, DecimalAttribute, DefaultTo, @@ -372,6 +374,36 @@ export interface AdminTransferTokenPermission extends CollectionTypeSchema { }; } +export interface ApiFooterFooter extends SingleTypeSchema { + info: { + singularName: "footer"; + pluralName: "footers"; + displayName: "Footer"; + description: ""; + }; + options: { + draftAndPublish: true; + }; + attributes: { + links: ComponentAttribute<"website.link", true>; + createdAt: DateTimeAttribute; + updatedAt: DateTimeAttribute; + publishedAt: DateTimeAttribute; + createdBy: RelationAttribute< + "api::footer.footer", + "oneToOne", + "admin::user" + > & + PrivateAttribute; + updatedBy: RelationAttribute< + "api::footer.footer", + "oneToOne", + "admin::user" + > & + PrivateAttribute; + }; +} + export interface PluginUploadFile extends CollectionTypeSchema { info: { singularName: "file"; @@ -533,33 +565,17 @@ export interface PluginI18NLocale extends CollectionTypeSchema { }; } -export interface ApiFooterFooter extends SingleTypeSchema { +export interface WebsiteLink extends ComponentSchema { info: { - singularName: "footer"; - pluralName: "footers"; - displayName: "Footer"; + displayName: "Link"; description: ""; }; - options: { - draftAndPublish: true; - }; attributes: { - githubUrl: StringAttribute; - createdAt: DateTimeAttribute; - updatedAt: DateTimeAttribute; - publishedAt: DateTimeAttribute; - createdBy: RelationAttribute< - "api::footer.footer", - "oneToOne", - "admin::user" - > & - PrivateAttribute; - updatedBy: RelationAttribute< - "api::footer.footer", - "oneToOne", - "admin::user" - > & - PrivateAttribute; + url: StringAttribute & RequiredAttribute; + label: StringAttribute & RequiredAttribute; + target: EnumerationAttribute<["New page", "Same page"]> & + RequiredAttribute & + DefaultTo<"New page">; }; } @@ -573,10 +589,11 @@ declare global { "admin::api-token-permission": AdminApiTokenPermission; "admin::transfer-token": AdminTransferToken; "admin::transfer-token-permission": AdminTransferTokenPermission; + "api::footer.footer": ApiFooterFooter; "plugin::upload.file": PluginUploadFile; "plugin::upload.folder": PluginUploadFolder; "plugin::i18n.locale": PluginI18NLocale; - "api::footer.footer": ApiFooterFooter; + "website.link": WebsiteLink; } } } diff --git a/src/api/footer/content-types/footer/schema.json b/src/api/footer/content-types/footer/schema.json index 4701c68..1c0ea83 100644 --- a/src/api/footer/content-types/footer/schema.json +++ b/src/api/footer/content-types/footer/schema.json @@ -12,8 +12,11 @@ }, "pluginOptions": {}, "attributes": { - "githubUrl": { - "type": "string" + "links": { + "type": "component", + "repeatable": true, + "component": "website.link", + "required": false } } } diff --git a/src/components/website/link.json b/src/components/website/link.json new file mode 100644 index 0000000..9be9aa4 --- /dev/null +++ b/src/components/website/link.json @@ -0,0 +1,25 @@ +{ + "collectionName": "components_website_links", + "info": { + "displayName": "Link", + "description": "" + }, + "options": {}, + "attributes": { + "url": { + "type": "string", + "required": true, + "regex": "/https?:\\/\\/(?:www\\.|(?!www))[^\\s.]+\\.[^\\s]{2,}/gm" + }, + "label": { + "type": "string", + "required": true + }, + "target": { + "type": "enumeration", + "enum": ["New page", "Same page"], + "default": "New page", + "required": true + } + } +}