Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor SEO Plugin Types for Enhanced Type Safety and Structured Document Handling #8123

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JarekToro
Copy link

Description

This pull request refactors the SEO plugin types to introduce TypedFormDocument and TypedFormField types, enhancing the type safety and flexibility of the document objects used in the SEO generation functions (GenerateTitle, GenerateDescription, GenerateImage, and GenerateURL). By replacing the generic doc type with TypedFormDocument, we ensure that each field within the document is well-defined, predictable, and type-checked, reducing potential errors and improving developer experience when extending or maintaining these functions. This change is aimed at enhancing the robustness of the SEO plugin’s type definitions, making them more intuitive and aligned with the evolving architecture of the Payload CMS.

Primary Motivation was the fact that the doc param in the generate functions is not the type of the generated types from payload. It is a an object with FormField values. This is not readily apparent.

This also adjusts the Generate function types to allow for a generic to be passed in.

From GenerateTitle = <T = any>(
To GenerateTitle<T = any> = (

  • I have read and understand the CONTRIBUTING.md document in this repository.

Type of change

  • Chore (non-breaking change which does not add functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Change to the templates directory (does not affect core functionality)
  • Change to the examples directory (does not affect core functionality)
  • This change requires a documentation update

Checklist:

Honestly for these guys I can't confirm. Im running this in GitHub codebases and from the get go before any changes I could not get a build to work. But I think this is purely the codespaces env issue.

  • [~] I have added tests that prove my fix is effective or that my feature works
  • [~] Existing test suite passes locally with my changes
  • [~] I have made corresponding changes to the documentation
@JarekToro JarekToro marked this pull request as ready for review September 9, 2024 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant