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

examples: Updating WordPress example to Next 14 #62447

Open
wants to merge 16 commits into
base: canary
Choose a base branch
from

Conversation

Bjornnyborg
Copy link

Updating the WordPress example, to a more modern example.

Key features:

  • robots.ts: This automatically gets the robots.txt of the API route and serves it on the /robots.txt route.
  • sitemap.ts: This automatically gets all paths from the API and generates a sitemap to serve on the /sitemap.xml route.
  • middleware.ts: This contains a middleware function that checks the users path for stored redirects, and redirects the user if a match is found.
  • [[...slug]]: This is the catch-all route that is used to render all pages. It is important that this route is not removed, as it is used to render all pages. It fetches the ContentType and renders the corresponding
  • not-found.tsx: This page is used for dynamic 404 handling - adjust the database id to match your decired WordPress page, and make sure the WordPress slug is "not-found", your 404 page will then be editable from your CMS.
  • codegen.ts: Automatic type generation for your WordPress installation
  • Draft Mode: Seamless Preview / Draft Preview support, using authentication through WPGraphQL JWT Authentication and Next.js Draft Mode
  • On Demand Cache Revalidation: Including a bare minimum WordPress theme that implements cache revalidation, WordPress link rewrites and other utils for integrating with Next.js

✅ The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md

✅ Make sure the linting passes by running pnpm build && pnpm lint. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

@Bjornnyborg Bjornnyborg requested review from ismaelrumzan and delbaoliveira and removed request for a team February 23, 2024 14:23
@ijjk ijjk added the examples Issue/PR related to examples label Feb 23, 2024
@Bjornnyborg Bjornnyborg force-pushed the example/cms-wordpress-app-router branch from d3d7e58 to 80d7e6a Compare February 27, 2024 19:37
@leerob
Copy link
Member

leerob commented Aug 26, 2024

Thanks for this suggestion!

  • Could we remove the unnecessary code comments, please? Ideally we can name the functions/variables in a way that are self-documenting.
  • Could you try to remove unneeded dependencies? i.e. doing GraphQL over fetch versus bringing in Apollo.
  • Can you share a working deployment so we can try this out?
  • Could you address the merge conflicts, plase?

@samcx
Copy link
Member

samcx commented Aug 26, 2024

@Bjornnyborg Thank you for submitting a PR!

If you can you address the comments, above, we will be able to progress with this.

…ic type generation, redirect handling, robots.txt, sitemap.xml and seamless preview/draft preview functionality
@Bjornnyborg Bjornnyborg force-pushed the example/cms-wordpress-app-router branch from 80d7e6a to 5d65b98 Compare August 26, 2024 16:22
@ijjk
Copy link
Member

ijjk commented Aug 26, 2024

Allow CI Workflow Run

  • approve CI run for commit: 5d65b98

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

1 similar comment
@ijjk
Copy link
Member

ijjk commented Aug 26, 2024

Allow CI Workflow Run

  • approve CI run for commit: 5d65b98

Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer

Copy link

socket-security bot commented Aug 26, 2024

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@graphql-codegen/cli@5.0.0 environment, filesystem, network, shell, unsafe +40 3.46 MB dotansimha
npm/@graphql-codegen/client-preset@4.3.3 None +9 854 kB dotansimha
npm/@graphql-codegen/schema-ast@4.1.0 None 0 11.3 kB dotansimha

View full report↗︎

@samcx samcx added the CI approved Approve running CI for fork label Aug 26, 2024
@Bjornnyborg
Copy link
Author

Hey @leerob and @samcx ! Thanks for getting back on this PR. 😊

I have updated the PR now:

  • Removed unnecessary code comments and auto generated files
  • I am actually already doing the requests with fetch, the apollo.config was only for enabling auto-completion for the queries, using the Apollo VS Code plugin - this is actually optional, so i added an example to the ReadMe, and removed the config file.
  • Working deployement: https://next-js-phi-fawn.vercel.app/ - the WordPress is located here: https://headless.29x.dk/wp-admin - if you want i can invite you guys to the WordPress backend too.
  • Merge conflicts resolved

Anything else i should improve? 😊

@samcx
Copy link
Member

samcx commented Aug 27, 2024

@Bjornnyborg Not sure if it was intentional, but it seems the navigation is waiting to load data—could there be a better way to implement this?

@Bjornnyborg
Copy link
Author

@samcx Good catch! Added the generateStaticParams to the Catch-All route, returning and empty array to have the ISR functionality enabled. 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI approved Approve running CI for fork examples Issue/PR related to examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants