Skip to content

Conversation

@alcercu
Copy link
Contributor

@alcercu alcercu commented Jan 13, 2025

Summary by CodeRabbit

  • New Content Types

    • Added schemas for multiple home page sections including:
      • Case Studies
      • Get in Touch
      • How Kleros Works
      • Learn Posts
      • Start Earning
  • New Components

    • Introduced LinkCard component
    • Added Introduction component with heading, link, and closing text
  • Backend Infrastructure

    • Created corresponding controllers, routes, and services for each new content type
    • Implemented using Strapi framework's core factory methods

@alcercu alcercu requested a review from tractorss January 13, 2025 14:38
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 13, 2025

Walkthrough

This pull request introduces several new content types and components for the CMS backend, focusing on home page sections such as case studies, get in touch, how Kleros works, learn posts, and start earning. The changes involve creating JSON schema files, controllers, routes, and services for each section using Strapi's framework. Additionally, two new components (LinkCard and Introduction) are added to support the content structure. These modifications enhance the CMS's ability to manage and organize home page content with a consistent and structured approach.

Changes

File Path Change Summary
cms-backend/src/api/*/content-types/*/schema.json Added schemas for home page sections: case studies, get in touch, how Kleros works, learn posts, start earning
cms-backend/src/api/*/controllers/*.ts Created Strapi core controllers for each home page section
cms-backend/src/api/*/routes/*.ts Implemented core routers for each home page section
cms-backend/src/api/*/services/*.ts Established core services for each home page section
cms-backend/src/components/content/link-card.json New LinkCard component with icon, title, subtitle, and link attributes
cms-backend/src/components/home/introduction.json New Introduction component with heading text, link, and closing text

Possibly related PRs

Suggested reviewers

  • Harman-singh-waraich

Poem

🐰 Hop, hop, hooray! New schemas are here to play,
Content types dancing in Strapi's light,
Components linking with all their might,
From case studies to earning's bright way,
Our CMS grows stronger today! 🌟


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@netlify
Copy link

netlify bot commented Jan 13, 2025

Deploy Preview for kleros-website-v2 ready!

Name Link
🔨 Latest commit 9f81968
🔍 Latest deploy log https://app.netlify.com/sites/kleros-website-v2/deploys/67853a6fb207840008400de0
😎 Deploy Preview https://deploy-preview-47--kleros-website-v2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Nitpick comments (15)
cms-backend/src/api/home-get-in-touch-section/routes/home-get-in-touch-section.ts (1)

1-3: Enhance documentation with usage examples

While the documentation is present, consider adding examples of available routes and their purposes to improve developer experience.

Add usage examples like:

 /**
  * home-get-in-touch-section router
+ *
+ * Available routes:
+ * - GET /api/home-get-in-touch-section
+ * - PUT /api/home-get-in-touch-section
+ * - DELETE /api/home-get-in-touch-section
  */
cms-backend/src/api/home-get-in-touch-section/services/home-get-in-touch-section.ts (1)

1-3: Enhance service documentation with available operations

While the documentation is present, consider adding examples of available service operations to improve maintainability.

Add operation examples like:

 /**
  * home-get-in-touch-section service
+ *
+ * Available operations:
+ * - find: Retrieve the section content
+ * - update: Update the section content
+ * - delete: Delete the section content
  */
cms-backend/src/api/home-get-in-touch-section/content-types/home-get-in-touch-section/schema.json (2)

31-36: Restrict media types for icon field

The icon field allows all media types (images, files, videos, audios) which seems too permissive for what should typically be an image icon.

Consider restricting to images only:

   "allowedTypes": [
-    "images",
-    "files",
-    "videos",
-    "audios"
+    "images"
   ],

14-20: Add string length validation for text fields

Consider adding max length constraints for the text fields to prevent overly long content that might affect UI layout.

Add maxLength validation:

   "title": {
     "type": "string",
-    "required": true
+    "required": true,
+    "maxLength": 100
   },
   "subtitle": {
-    "type": "string"
+    "type": "string",
+    "maxLength": 200
   },
   ...
   "cta_text": {
     "type": "string",
-    "required": true
+    "required": true,
+    "maxLength": 50
   },

Also applies to: 26-29

cms-backend/src/api/home-how-kleros-works-section/routes/home-how-kleros-works-section.ts (1)

1-3: Enhance documentation with endpoint details.

Consider adding more detailed documentation that describes the available endpoints and their purposes.

 /**
  * home-how-kleros-works-section router
+ *
+ * Available endpoints:
+ * - GET    /api/home-how-kleros-works-section
+ * - POST   /api/home-how-kleros-works-section
+ * - PUT    /api/home-how-kleros-works-section
+ * - DELETE /api/home-how-kleros-works-section
  */
cms-backend/src/api/home-how-kleros-works-section/controllers/home-how-kleros-works-section.ts (1)

1-3: Enhance documentation with controller functionality.

Consider adding more detailed documentation that describes the available controller actions.

 /**
  * home-how-kleros-works-section controller
+ *
+ * Standard Strapi controller providing:
+ * - find: Get the single type entry
+ * - update: Update the single type entry
+ * - delete: Delete the single type entry
+ * - create: Create a single type entry if none exists
  */
cms-backend/src/api/home-how-kleros-works-section/content-types/home-how-kleros-works-section/schema.json (3)

26-36: Consider restricting media types for explainer field.

The explainer field currently accepts all media types (images, files, videos, audios). Consider restricting it to only the required types based on the actual use case to prevent incorrect media uploads.

     "explainer": {
       "allowedTypes": [
-        "images",
-        "files",
-        "videos",
-        "audios"
+        "images",
+        "videos"
       ],
       "type": "media",
       "multiple": false,
       "required": true
     }

14-25: Add validation rules and descriptions for text fields.

The string fields (label, title, subtitle) would benefit from additional validation rules and descriptions to guide content editors.

     "label": {
       "type": "string",
-      "required": true
+      "required": true,
+      "minLength": 2,
+      "maxLength": 50,
+      "description": "Short identifier for the section"
     },
     "title": {
       "type": "string",
-      "required": true
+      "required": true,
+      "minLength": 5,
+      "maxLength": 100,
+      "description": "Main heading of the section"
     },
     "subtitle": {
       "type": "string",
-      "required": true
+      "required": true,
+      "minLength": 10,
+      "maxLength": 200,
+      "description": "Supporting text below the title"
     },

4-8: Consider adding i18n support.

If the website needs to support multiple languages in the future, consider enabling internationalization for this content type.

   "info": {
     "singularName": "home-how-kleros-works-section",
     "pluralName": "home-how-kleros-works-sections",
-    "displayName": "HomeHowKlerosWorksSection"
+    "displayName": "HomeHowKlerosWorksSection",
+    "description": "Configure the How Kleros Works section of the homepage"
   },
+  "pluginOptions": {
+    "i18n": {
+      "localized": true
+    }
+  },
cms-backend/src/api/home-learn-posts-section/routes/home-learn-posts-section.ts (1)

1-3: Enhance documentation with available routes.

Consider expanding the JSDoc comment to document the available routes that Strapi's core router will generate (e.g., GET, POST, PUT, DELETE endpoints).

 /**
  * home-learn-posts-section router
+ *
+ * Generated routes:
+ * - GET /api/home-learn-posts-section
+ * - POST /api/home-learn-posts-section
+ * - PUT /api/home-learn-posts-section
+ * - DELETE /api/home-learn-posts-section
  */
cms-backend/src/api/home-learn-posts-section/services/home-learn-posts-section.ts (1)

1-3: Enhance documentation with available service methods.

Consider expanding the JSDoc comment to document the available service methods that Strapi's core service will generate.

 /**
  * home-learn-posts-section service
+ *
+ * Available methods:
+ * - find
+ * - findOne
+ * - create
+ * - update
+ * - delete
  */
cms-backend/src/api/home-learn-posts-section/controllers/home-learn-posts-section.ts (1)

1-3: Enhance documentation with available controller actions.

Consider expanding the JSDoc comment to document the available controller actions that Strapi's core controller will generate.

 /**
  * home-learn-posts-section controller
+ *
+ * Available actions:
+ * - find: GET /api/home-learn-posts-section
+ * - findOne: GET /api/home-learn-posts-section/:id
+ * - create: POST /api/home-learn-posts-section
+ * - update: PUT /api/home-learn-posts-section/:id
+ * - delete: DELETE /api/home-learn-posts-section/:id
  */
cms-backend/src/api/home-start-earning-section/services/home-start-earning-section.ts (1)

1-3: Enhance documentation with available service methods.

Consider expanding the JSDoc comment to document the available service methods that Strapi's core service will generate.

 /**
  * home-start-earning-section service
+ *
+ * Available methods:
+ * - find
+ * - findOne
+ * - create
+ * - update
+ * - delete
  */
cms-backend/src/components/home-page/card.json (1)

17-26: Consider restricting icon media types

The icon field currently accepts all media types including files, videos, and audios. Since this is a card component, consider restricting to only images for consistency in UI rendering.

     "allowedTypes": [
-      "images",
-      "files",
-      "videos",
-      "audios"
+      "images"
     ],
cms-backend/src/api/home-learn-posts-section/content-types/home-learn-posts-section/schema.json (1)

18-20: Consider using rich text for subtitle

For better content formatting capabilities, consider using richtext type instead of string for the subtitle field.

   "subtitle": {
-    "type": "string"
+    "type": "richtext"
   }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7175c6f and 140d25a.

⛔ Files ignored due to path filters (2)
  • cms-backend/types/generated/components.d.ts is excluded by !**/generated/**
  • cms-backend/types/generated/contentTypes.d.ts is excluded by !**/generated/**
📒 Files selected for processing (25)
  • cms-backend/src/api/blog-post/content-types/blog-post/schema.json (1 hunks)
  • cms-backend/src/api/blog-post/controllers/blog-post.ts (1 hunks)
  • cms-backend/src/api/blog-post/routes/blog-post.ts (1 hunks)
  • cms-backend/src/api/blog-post/services/blog-post.ts (1 hunks)
  • cms-backend/src/api/home-case-studies-section/content-types/home-case-studies-section/schema.json (1 hunks)
  • cms-backend/src/api/home-case-studies-section/controllers/home-case-studies-section.ts (1 hunks)
  • cms-backend/src/api/home-case-studies-section/routes/home-case-studies-section.ts (1 hunks)
  • cms-backend/src/api/home-case-studies-section/services/home-case-studies-section.ts (1 hunks)
  • cms-backend/src/api/home-get-in-touch-section/content-types/home-get-in-touch-section/schema.json (1 hunks)
  • cms-backend/src/api/home-get-in-touch-section/controllers/home-get-in-touch-section.ts (1 hunks)
  • cms-backend/src/api/home-get-in-touch-section/routes/home-get-in-touch-section.ts (1 hunks)
  • cms-backend/src/api/home-get-in-touch-section/services/home-get-in-touch-section.ts (1 hunks)
  • cms-backend/src/api/home-how-kleros-works-section/content-types/home-how-kleros-works-section/schema.json (1 hunks)
  • cms-backend/src/api/home-how-kleros-works-section/controllers/home-how-kleros-works-section.ts (1 hunks)
  • cms-backend/src/api/home-how-kleros-works-section/routes/home-how-kleros-works-section.ts (1 hunks)
  • cms-backend/src/api/home-how-kleros-works-section/services/home-how-kleros-works-section.ts (1 hunks)
  • cms-backend/src/api/home-learn-posts-section/content-types/home-learn-posts-section/schema.json (1 hunks)
  • cms-backend/src/api/home-learn-posts-section/controllers/home-learn-posts-section.ts (1 hunks)
  • cms-backend/src/api/home-learn-posts-section/routes/home-learn-posts-section.ts (1 hunks)
  • cms-backend/src/api/home-learn-posts-section/services/home-learn-posts-section.ts (1 hunks)
  • cms-backend/src/api/home-start-earning-section/content-types/home-start-earning-section/schema.json (1 hunks)
  • cms-backend/src/api/home-start-earning-section/controllers/home-start-earning-section.ts (1 hunks)
  • cms-backend/src/api/home-start-earning-section/routes/home-start-earning-section.ts (1 hunks)
  • cms-backend/src/api/home-start-earning-section/services/home-start-earning-section.ts (1 hunks)
  • cms-backend/src/components/home-page/card.json (1 hunks)
✅ Files skipped from review due to trivial changes (10)
  • cms-backend/src/api/home-get-in-touch-section/controllers/home-get-in-touch-section.ts
  • cms-backend/src/api/blog-post/controllers/blog-post.ts
  • cms-backend/src/api/home-case-studies-section/services/home-case-studies-section.ts
  • cms-backend/src/api/blog-post/routes/blog-post.ts
  • cms-backend/src/api/home-case-studies-section/controllers/home-case-studies-section.ts
  • cms-backend/src/api/home-start-earning-section/controllers/home-start-earning-section.ts
  • cms-backend/src/api/blog-post/services/blog-post.ts
  • cms-backend/src/api/home-case-studies-section/routes/home-case-studies-section.ts
  • cms-backend/src/api/home-start-earning-section/routes/home-start-earning-section.ts
  • cms-backend/src/api/home-how-kleros-works-section/services/home-how-kleros-works-section.ts
🔇 Additional comments (8)
cms-backend/src/api/home-get-in-touch-section/routes/home-get-in-touch-section.ts (1)

5-7: LGTM! Implementation follows Strapi's best practices

The router implementation correctly uses Strapi's factory pattern and follows naming conventions.

cms-backend/src/api/home-get-in-touch-section/services/home-get-in-touch-section.ts (1)

5-7: LGTM! Service implementation follows best practices

The service implementation correctly uses Strapi's factory pattern and aligns with the router implementation.

cms-backend/src/api/home-get-in-touch-section/content-types/home-get-in-touch-section/schema.json (1)

1-41: LGTM! Schema structure follows Strapi conventions

The overall schema structure is well-organized and follows Strapi's content type conventions. The use of singleType is appropriate for a unique section, and the relationships are properly defined.

cms-backend/src/api/home-how-kleros-works-section/content-types/home-how-kleros-works-section/schema.json (1)

1-38: LGTM on the overall structure!

The schema follows Strapi's best practices for single type content structures. The use of draftAndPublish is appropriate for managing content updates.

cms-backend/src/api/home-learn-posts-section/routes/home-learn-posts-section.ts (1)

5-7: LGTM!

The implementation follows Strapi's recommended pattern using the factory method to create core router functionality.

cms-backend/src/api/home-learn-posts-section/services/home-learn-posts-section.ts (1)

5-7: LGTM!

The implementation follows Strapi's recommended pattern using the factory method to create core service functionality.

cms-backend/src/api/home-learn-posts-section/controllers/home-learn-posts-section.ts (1)

5-7: LGTM!

The implementation follows Strapi's recommended pattern using the factory method to create core controller functionality.

cms-backend/src/api/home-start-earning-section/services/home-start-earning-section.ts (1)

5-7: LGTM!

The implementation follows Strapi's recommended pattern using the factory method to create core service functionality.

Comment on lines 28 to 30
"url": {
"type": "string"
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add URL validation

The URL field should include pattern validation to ensure valid URLs are entered.

   "url": {
     "type": "string"
+    "regex": "^(https?:\\/\\/)?([\\da-z\\.-]+)\\.([a-z\\.]{2,6})([\\/\\w \\.-]*)*\\/?$"
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"url": {
"type": "string"
}
"url": {
"type": "string",
"regex": "^(https?:\\/\\/)?([\\da-z\\.-]+)\\.([a-z\\.]{2,6})([\\/\\w \\.-]*)*\\/?$"
}

Comment on lines 18 to 21
"subtitle": {
"type": "text",
"required": false
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Maintain consistency in subtitle field type

The subtitle field uses text type while other sections use string. Consider using the same type across all sections for consistency.

   "subtitle": {
-    "type": "text",
-    "required": false
+    "type": "richtext"
   }

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines 22 to 26
"Cards": {
"type": "component",
"repeatable": true,
"component": "home-page.card"
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Follow consistent field naming convention

The Cards field name starts with an uppercase letter, which is inconsistent with JavaScript/JSON conventions. Consider renaming to cards.

-    "Cards": {
+    "cards": {
       "type": "component",
       "repeatable": true,
       "component": "home-page.card"
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"Cards": {
"type": "component",
"repeatable": true,
"component": "home-page.card"
},
"cards": {
"type": "component",
"repeatable": true,
"component": "home-page.card"
},

Comment on lines 27 to 31
"cta": {
"type": "component",
"repeatable": true,
"component": "content.section"
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

CTA should not be repeatable

The codebase consistently uses single CTAs in sections, and this appears to be the only instance of a repeatable CTA. The suggested change to make it non-repeatable aligns with both the codebase patterns and UI best practices.

🔗 Analysis chain

Verify CTA repeatability requirement

The cta component is marked as repeatable. Typically, a section would have a single call-to-action. Please verify if multiple CTAs are intended.

     "cta": {
       "type": "component",
-      "repeatable": true,
+      "repeatable": false,
       "component": "content.section"
     }
🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Find all schema files in the cms-backend
fd schema.json --type f

# Look for other occurrences of CTA fields
rg -A 3 '"cta":\s*{' --type json

# Find the component definition for content.section
fd section.json --type f

Length of output: 4935


Script:

#!/bin/bash
# Check the content.section component definition
cat cms-backend/src/components/content/section.json

# Search for CTA fields with fixed regex
rg -A 3 '"cta"' --type json

# Look for similar section schemas
cat cms-backend/src/api/home-get-in-touch-section/content-types/home-get-in-touch-section/schema.json

Length of output: 1829

"type": "string",
"required": false
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add essential blog post fields

The schema is missing common blog post fields. Consider adding:

  • content (richtext): The main blog content
  • author (relation): Link to user/author
  • publishDate (datetime): Explicit publish date
  • tags (relation): Blog post categories/tags
+    "content": {
+      "type": "richtext",
+      "required": true
+    },
+    "author": {
+      "type": "relation",
+      "relation": "manyToOne",
+      "target": "plugin::users-permissions.user"
+    },
+    "publishDate": {
+      "type": "datetime"
+    },
+    "tags": {
+      "type": "relation",
+      "relation": "manyToMany",
+      "target": "api::tag.tag"
+    }

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines 31 to 38
"url": {
"type": "string",
"required": true
},
"urlName": {
"type": "string",
"required": false
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Clarify URL field strategy

The schema has both url and urlName fields which seem redundant. Consider:

  1. Using a single field for the URL
  2. Generating the URL from the title using a slug transform
-    "url": {
-      "type": "string",
-      "required": true
-    },
-    "urlName": {
-      "type": "string",
-      "required": false
-    }
+    "slug": {
+      "type": "uid",
+      "targetField": "title"
+    }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"url": {
"type": "string",
"required": true
},
"urlName": {
"type": "string",
"required": false
}
"slug": {
"type": "uid",
"targetField": "title"
}

"subtitle": {
"type": "string"
},
"link": {
Copy link
Contributor

@tractorss tractorss Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the Button/ArrowLink component combines both link and text , maybe use that here 🤔

so, combine "link" and "cta_text" to button/arrowLink, single component

"type": "string",
"required": true
},
"explainer": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we would require, two explainer Icons , one for Desktop and one for Mobile

"subtitle": {
"type": "string"
},
"blog_posts": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is for the Decentralised Justice section 🤔
I would recommend making a LearnCard (or some other name) component instead of using BlogPost collection type, and use Button/ArrowLink component in that component. For example, the Yellow Paper link is already available in Link types, we would not want to re-specify it in blog post 🤔
wdyt

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also , I think we are missing type for this component 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense 🤔

"subtitle": {
"type": "string"
},
"Cards": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like this for above, we are doing something similar with other pages too, which have these cards

@alcercu alcercu requested a review from tractorss January 13, 2025 16:08
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
cms-backend/src/api/home-how-kleros-works-section/content-types/home-how-kleros-works-section/schema.json (1)

27-37: 🛠️ Refactor suggestion

Rename fields and make desktop version required

Based on the previous review comment about requiring two explainer icons, consider these improvements:

  1. Rename fields to be more explicit about their purpose:
    • explainerexplainer_mobile
    • explainer_desktop → (keep as is)
  2. Make explainer_desktop required since it's a necessary companion to the mobile version

Apply this diff:

-    "explainer": {
+    "explainer_mobile": {
       "type": "media",
       "multiple": false,
       "required": true,
       "allowedTypes": [
         "images",
         "files",
         "videos",
         "audios"
       ]
     },
     "explainer_desktop": {
       "allowedTypes": [
         "images",
         "files",
         "videos",
         "audios"
       ],
       "type": "media",
-      "multiple": false
+      "multiple": false,
+      "required": true
     }

Also applies to: 38-47

🧹 Nitpick comments (5)
cms-backend/src/api/home-learn-posts-section/content-types/home-learn-posts-section/schema.json (2)

4-9: Add a descriptive summary in the description field.

Consider adding a clear description that explains the purpose and usage of this section (e.g., "Manages the learn posts section content displayed on the home page").

   "info": {
     "singularName": "home-learn-posts-section",
     "pluralName": "home-learn-posts-sections",
     "displayName": "HomeLearnPostsSection",
-    "description": ""
+    "description": "Manages the learn posts section content displayed on the home page, including title, subtitle, and associated cards."
   },

14-33: Consider adding field validation constraints.

To ensure data integrity and consistent content structure, consider adding validation constraints:

     "title": {
       "type": "string",
-      "required": true
+      "required": true,
+      "minLength": 1,
+      "maxLength": 100
     },
     "subtitle": {
-      "type": "string"
+      "type": "string",
+      "maxLength": 200
     },

Additionally, consider adding a minimum items constraint for the cards to ensure at least one card is present:

     "cards": {
       "type": "component",
       "repeatable": true,
-      "component": "content.link-card"
+      "component": "content.link-card",
+      "min": 1
     },
cms-backend/src/components/content/link-card.json (3)

3-6: Add a description for better documentation.

The empty description field should be populated to help content editors and developers understand the purpose and usage of this component.

   "info": {
     "displayName": "LinkCard",
-    "description": ""
+    "description": "A card component with an icon, title, subtitle, and a clickable link, used for displaying interactive content in sections like home-learn-posts."
   },

9-19: Restrict media types and consider making icon required.

For a LinkCard component:

  1. Consider restricting media types to only images for consistent UI
  2. Consider making the icon required if it's essential for the card's visual identity
     "icon": {
       "type": "media",
       "multiple": false,
-      "required": false,
+      "required": true,
       "allowedTypes": [
-        "images",
-        "files",
-        "videos",
-        "audios"
+        "images"
       ]
     },

20-26: Add max length validation for text fields.

Consider adding maximum length constraints to prevent overly long text that could break the UI layout.

     "title": {
       "type": "string",
-      "required": true
+      "required": true,
+      "maxLength": 100
     },
     "subtitle": {
-      "type": "string"
+      "type": "string",
+      "maxLength": 200
     },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 140d25a and 9f81968.

⛔ Files ignored due to path filters (2)
  • cms-backend/types/generated/components.d.ts is excluded by !**/generated/**
  • cms-backend/types/generated/contentTypes.d.ts is excluded by !**/generated/**
📒 Files selected for processing (7)
  • cms-backend/src/api/home-case-studies-section/content-types/home-case-studies-section/schema.json (1 hunks)
  • cms-backend/src/api/home-get-in-touch-section/content-types/home-get-in-touch-section/schema.json (1 hunks)
  • cms-backend/src/api/home-how-kleros-works-section/content-types/home-how-kleros-works-section/schema.json (1 hunks)
  • cms-backend/src/api/home-learn-posts-section/content-types/home-learn-posts-section/schema.json (1 hunks)
  • cms-backend/src/api/home-start-earning-section/content-types/home-start-earning-section/schema.json (1 hunks)
  • cms-backend/src/components/content/link-card.json (1 hunks)
  • cms-backend/src/components/home/introduction.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • cms-backend/src/components/home/introduction.json
🚧 Files skipped from review as they are similar to previous changes (3)
  • cms-backend/src/api/home-get-in-touch-section/content-types/home-get-in-touch-section/schema.json
  • cms-backend/src/api/home-case-studies-section/content-types/home-case-studies-section/schema.json
  • cms-backend/src/api/home-start-earning-section/content-types/home-start-earning-section/schema.json
🔇 Additional comments (3)
cms-backend/src/api/home-learn-posts-section/content-types/home-learn-posts-section/schema.json (1)

27-32: Verify if this addresses the missing Figma component.

Based on the previous review comments, there was a missing component from the Figma design. Please verify if the home.introduction component addresses this requirement.

cms-backend/src/api/home-how-kleros-works-section/content-types/home-how-kleros-works-section/schema.json (1)

1-13: Content type configuration looks good!

The schema follows Strapi's best practices with appropriate naming conventions and content management options.

cms-backend/src/components/content/link-card.json (1)

27-31: Verify the button-link component dependency.

The link field references content.button-link component. Let's verify this dependency exists.

✅ Verification successful

Dependency verification successful

The referenced content.button-link component exists at the expected location.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the referenced button-link component exists
fd --type f "button-link.json" cms-backend/src/components/content/

Length of output: 118

Comment on lines +31 to +36
"allowedTypes": [
"images",
"files",
"videos",
"audios"
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Restrict media types to images only

Since these fields are intended for explainer icons, they should only accept image files. The current configuration allows unnecessary media types like files, videos, and audios.

Apply this diff to both media fields:

       "allowedTypes": [
-        "images",
-        "files",
-        "videos",
-        "audios"
+        "images"
       ]

Also applies to: 39-44

Copy link
Contributor

@tractorss tractorss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@tractorss tractorss merged commit 4a4fff4 into master Jan 14, 2025
5 checks passed
@tractorss tractorss deleted the feat(cms)/add-home-types branch January 14, 2025 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants