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

Feature/pages router #49

Merged
merged 15 commits into from
May 6, 2024
Merged

Feature/pages router #49

merged 15 commits into from
May 6, 2024

Conversation

jsdalton
Copy link
Member

@jsdalton jsdalton commented May 2, 2024

Purpose

  • Provide an API route for pages router to enable Draft Mode
  • Clean up and consolidate shared code

Description

TODO

  • Expose pages-router package
  • Add tests for utils

Testing steps

Breaking Changes

Design, Documentation, and/or References

Deployment

@jsdalton jsdalton requested a review from a team as a code owner May 2, 2024 18:14
@jsdalton jsdalton requested a review from matthew-gordon May 2, 2024 18:14
Copy link

@matthew-gordon matthew-gordon left a comment

Choose a reason for hiding this comment

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

Looks great. I think we just need to add to the exports and also add pages-router to the files in the package.json to make sure its referenced correctly:

...
  "files": [
    "dist",
    "app-router",
    "pages-router"
  ],
  "exports": {
    ".": {
      "import": "./dist/index.js",
      "require": "./dist/index.js",
      "types": "./dist/index.d.ts"
    },
    "./app-router": {
      "import": "./dist/app-router/handlers/enable-draftjs",
      "require": "./dist/app-router/handlers/enable-draft.js",
      "types": "./dist/app-router/handlers/enable-draft.d.ts"
    },
    "./pages-router": {
      "import": "./dist/pages-router/handlers/enable-draft.js",
      "require": "./dist/pages-router/handlers/enable-draft.js",
      "types": "./dist/pages-router/handlers/enable-draft.d.ts"
    }
  },
...

@jsdalton jsdalton requested a review from matthew-gordon May 2, 2024 22:01
README.md Outdated Show resolved Hide resolved
@matthew-gordon
Copy link

ok tested this locally, just a few changes needed to get this working as expected, the new pattern for this import/export will look like this in a project:

export { default as handler } from "@contentful/vercel-nextjs-toolkit/pages-router";

Pages router errors out if we dont have a default export handler from the api file.

@matthew-gordon matthew-gordon self-requested a review May 3, 2024 19:41
@matthew-gordon
Copy link

This looks good pending the few things we talked about shaping this back up last week 👍

@jsdalton jsdalton merged commit c068d0a into main May 6, 2024
1 check passed
@jsdalton jsdalton deleted the feature/pages-router branch May 6, 2024 17:23
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.

2 participants