Skip to content

Commit

Permalink
feat(footer-api): ✨ Add link components to footer content type
Browse files Browse the repository at this point in the history
  • Loading branch information
navin-moorthy committed May 24, 2023
1 parent 9729f44 commit 00eb7e2
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 27 deletions.
2 changes: 1 addition & 1 deletion http/api.http
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
###
# Get the footer contents

GET {{baseURL}}/api/footer
GET {{baseURL}}/api/footer?populate=*
Authorization: Bearer {{$dotenv API_TOKEN}}
65 changes: 41 additions & 24 deletions schemas.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import {
BigIntegerAttribute,
BooleanAttribute,
CollectionTypeSchema,
ComponentAttribute,
ComponentSchema,
DateTimeAttribute,
DecimalAttribute,
DefaultTo,
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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">;
};
}

Expand All @@ -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;
}
}
}
7 changes: 5 additions & 2 deletions src/api/footer/content-types/footer/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
},
"pluginOptions": {},
"attributes": {
"githubUrl": {
"type": "string"
"links": {
"type": "component",
"repeatable": true,
"component": "website.link",
"required": false
}
}
}
25 changes: 25 additions & 0 deletions src/components/website/link.json
Original file line number Diff line number Diff line change
@@ -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
}
}
}

0 comments on commit 00eb7e2

Please sign in to comment.