Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Preview doesn't work with nested URIs #942

Open
colis opened this issue Feb 22, 2022 · 0 comments
Open

Preview doesn't work with nested URIs #942

colis opened this issue Feb 22, 2022 · 0 comments
Assignees

Comments

@colis
Copy link

colis commented Feb 22, 2022

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

// Check if preview mode is active and valid for current post (preview and post IDs or slugs match).
const isCurrentPostPreview =
preview &&
(postId === previewData?.post?.id ||
// Compare URIs with leading and trailing slashes stripped.
postId.replace(/^\/|\/$/g, '') ===
previewData?.post?.uri?.replace(/^\/|\/$/g, ''))

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants