nextjs-wordpress-starter icon indicating copy to clipboard operation
nextjs-wordpress-starter copied to clipboard

Preview doesn't work with nested URIs

Open colis opened this issue 2 years ago • 0 comments

Describe the bug Preview doesn't seem to be working when posts use nested URIs, e.g. /2022/02/22/hello-world/

To Reproduce

  1. Select the Day and name structure for the permalinks
  2. Edit an existing post without saving and click preview
  3. The frontend will display the post without the latest changes and the preview top bar is not visible

Expected behavior Unsaved changes and the preview top bar are both visible.

Additional context https://github.com/WebDevStudios/nextjs-wordpress-starter/blob/dab0be067678308c10f82a979c44b98ecd8ee933/frontend/functions/wordpress/postTypes/getPostTypeStaticProps.js#L154-L160

The problem seems to be on lines 159-160, where previewData?.post?.uri would be /2022/02/22/hello-world/ whereas postId would contain the slug, i.e. hello-world, therefore that check will always return false

colis avatar Feb 22 '22 16:02 colis