Open Hardeepex opened 8 months ago
00b6548a88
)Here are the sandbox execution logs prior to making any changes:
be952fa
Checking lib/api.ts for syntax errors... ✅ lib/api.ts has no syntax errors!
1/1 ✓Checking lib/api.ts for syntax errors... ✅ lib/api.ts has no syntax errors!
Sandbox passed on the latest main
, so sandbox checks will be enabled for this issue.
I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.
lib/api.ts
✓ https://github.com/thesameguyorg/isr-blog-nextjs-wordpress/commit/e14f9f0be65081680610597d5761e1779f5858dc Edit
Modify lib/api.ts with contents:
• Review the GraphQL queries in the `lib/api.ts` file. These queries are used to fetch data from your WordPress setup. If you want to fetch different data, you will need to modify these queries. For example, if you want to fetch a different set of fields for each post, you would modify the `PostFields` fragment in the `getPostAndMorePosts` function.
• Ensure that the `WORDPRESS_API_URL` environment variable is correctly set to the URL of your WordPress GraphQL endpoint. This is used in the `fetchAPI` function to make requests to the WordPress API.
--- +++ @@ -121,6 +121,7 @@ } } fragment PostFields on Post { + id title excerpt slug @@ -128,6 +129,7 @@ featuredImage { node { sourceUrl + altText } } author { @@ -138,6 +140,7 @@ categories { edges { node { + id name } } @@ -145,6 +148,7 @@ tags { edges { node { + id name } }
lib/api.ts
✓ Edit
Check lib/api.ts with contents:
Ran GitHub Actions for e14f9f0be65081680610597d5761e1779f5858dc:
• Vercel Preview Comments: ✓
README.md
✓ https://github.com/thesameguyorg/isr-blog-nextjs-wordpress/commit/8efad798f8102d83a732779fc2954afb3e718c04 Edit
Modify README.md with contents:
• Follow the instructions in the `README.md` file to configure your WordPress setup to serve as a headless CMS. This includes installing the WPGraphQL plugin, populating your WordPress site with content, and setting up environment variables.
• If you want to enable preview mode, follow the instructions in the `README.md` file to set up authentication for WPGraphQL and get a refresh token.
--- +++ @@ -72,6 +72,8 @@ - Once the plugin has been added, activate it from either the **Activate Plugin** button displayed after uploading or from the **Plugins** page. +- Ensure that the WPGraphQL plugin is properly configured by verifying that the GraphQL API is available at `yourwordpresssite.com/graphql`, replacing `yourwordpresssite.com` with your WordPress site's URL. + ![WPGraphQL installed](./docs/plugin-installed.png) #### GraphiQL @@ -88,6 +90,8 @@ - Use dummy data for the content - Pick an author from your WordPress users - Add a **Featured Image**. You can download one from [Unsplash](https://unsplash.com/) + +- Make sure to set a relevant title, content, and excerpt for the posts as this data will be used to display on your Next.js frontend. - Fill the **Excerpt** field ![New post](./docs/new-post.png) @@ -99,6 +103,8 @@ ### Step 3. Set up environment variables Copy the `.env.local.example` file in this directory to `.env.local` (which will be ignored by Git): + +- Acquire the necessary values for the environment variables as per the specifications and intended use of the Next.js frontend with the WordPress backend. This includes the URL to your WordPress GraphQL API endpoint. ```bash cp .env.local.example .env.local @@ -138,7 +144,7 @@ > Adding the WPGraphQL JWT plugin will disable your GraphQL API until you add a JWT secret ([GitHub issue](https://github.com/wp-graphql/wp-graphql-jwt-authentication/issues/91)). -Once that's done, you'll need to access the WordPress filesystem to add the secret required to validate JWT tokens. We recommend using SFTP — the instructions vary depending on your hosting provider. For example: +After activating the plugin, follow your hosting provider's instructions to gain access to the WordPress filesystem, where you'll add the JWT secret for authenticating requests: - [SFTP guide for WP Engine](https://wpengine.com/support/sftp/) - [SFTP guide for WordPress.com](https://wordpress.com/support/sftp/) @@ -170,6 +176,8 @@ Copy the `refreshToken` returned by the mutation, then open `.env.local`, and make the following changes: - Uncomment `WORDPRESS_AUTH_REFRESH_TOKEN` and set it to be the `refreshToken` you just received. + +- Be sure to secure your `WORDPRESS_AUTH_REFRESH_TOKEN` as it allows access to preview unpublished content. - Uncomment `WORDPRESS_PREVIEW_SECRET` and set it to be any random string (ideally URL friendly). Your `.env.local` file should look like this:
README.md
✓ Edit
Check README.md with contents:
Ran GitHub Actions for 8efad798f8102d83a732779fc2954afb3e718c04:
• Vercel Preview Comments: ✓
I have finished reviewing the code for completeness. I did not find errors for sweep/as_you_added_the_files_in_directory_for
.
💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request. Join Our Discord
i want to use headlrss wordpress for this directory it was the nextjs boilerplate for wordpress with nextjs using graphql how i can show the content in nextjs front from wordpress
Checklist
- [X] Modify `lib/api.ts` ✓ https://github.com/thesameguyorg/isr-blog-nextjs-wordpress/commit/e14f9f0be65081680610597d5761e1779f5858dc [Edit](https://github.com/thesameguyorg/isr-blog-nextjs-wordpress/edit/sweep/as_you_added_the_files_in_directory_for/lib/api.ts#L2-L211) - [X] Running GitHub Actions for `lib/api.ts` ✓ [Edit](https://github.com/thesameguyorg/isr-blog-nextjs-wordpress/edit/sweep/as_you_added_the_files_in_directory_for/lib/api.ts#L2-L211) - [X] Modify `README.md` ✓ https://github.com/thesameguyorg/isr-blog-nextjs-wordpress/commit/8efad798f8102d83a732779fc2954afb3e718c04 [Edit](https://github.com/thesameguyorg/isr-blog-nextjs-wordpress/edit/sweep/as_you_added_the_files_in_directory_for/README.md#L57-L218) - [X] Running GitHub Actions for `README.md` ✓ [Edit](https://github.com/thesameguyorg/isr-blog-nextjs-wordpress/edit/sweep/as_you_added_the_files_in_directory_for/README.md#L57-L218)