Skip to content

Fix ViewPostButton to show for all published posts#979

Open
busbyk wants to merge 5 commits intomainfrom
live-page-button-posts
Open

Fix ViewPostButton to show for all published posts#979
busbyk wants to merge 5 commits intomainfrom
live-page-button-posts

Conversation

@busbyk
Copy link
Collaborator

@busbyk busbyk commented Mar 7, 2026

Description

The ViewPostButton (live page button on Posts) was using getCanonicalUrlForSlug() which searches the navigation menu for the post's slug. Since most blog posts aren't linked in navigation, the function returned null and the button never rendered. This fix constructs the URL directly as /{center}/blog/{slug}, matching the actual route pattern.

Related Issues

Closes #709

Key Changes

  • Removed getCanonicalUrlForSlug dependency — posts don't need navigation lookup since they always live at /blog/{slug}
  • Reduced query depth from 2 to 0 (only slug, _status, and tenant are needed)
  • Moved _status check before resolveTenant() to avoid unnecessary work for draft posts

How to test

  1. Run pnpm dev and navigate to /admin
  2. Open any published post in the admin editor
  3. Verify the globe button appears in the document controls (top right)
  4. Click the globe button — it should open /{center}/blog/{slug} in a new tab
  5. Open a draft post — the globe button should NOT appear

Screenshots / Demo video

Migration Explanation

No migration needed — this is a UI-only change.

Future enhancements / Questions

…okup

The button was using getCanonicalUrlForSlug() which searches the navigation
menu — but most posts aren't in navigation, so the button never rendered.
Now constructs the URL directly as /{center}/blog/{slug}.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@busbyk busbyk self-assigned this Mar 7, 2026
@busbyk busbyk requested a review from rchlfryn March 7, 2026 00:13
@github-actions
Copy link

github-actions bot commented Mar 7, 2026

Preview deployment: https://live-page-button-posts.preview.avy-fx.org

Copy link
Collaborator

@rchlfryn rchlfryn left a comment

Choose a reason for hiding this comment

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

Looks good - can we add a test?

…t documents

Tests verify the globe button appears on published posts/pages and is hidden
on draft documents. Draft tests unpublish a document, assert the button is
gone, then re-publish to restore state. Also fixes the button's id attribute
to use a stable test selector.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@busbyk
Copy link
Collaborator Author

busbyk commented Mar 8, 2026

Looks good - can we add a test?

Tests added 🕺

@busbyk busbyk requested a review from rchlfryn March 8, 2026 18:55
Copy link
Collaborator

@rchlfryn rchlfryn left a comment

Choose a reason for hiding this comment

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

Nit pick - but LG

Copy link
Collaborator

Choose a reason for hiding this comment

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

⛏️ There are a lot of comments in this file. Do we want that?

I am fine either way but I think test variable should help explain what is happening which they do.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Cleaned up the comments a bit. A lot of them felt helpful to me but I see your point. Hopefully this is a nice middle ground.

@busbyk busbyk enabled auto-merge March 9, 2026 20:52
@busbyk busbyk added this pull request to the merge queue Mar 9, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 9, 2026
@busbyk busbyk added this pull request to the merge queue Mar 9, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 9, 2026
…n failures + use a longer timeout for published assertion
@busbyk busbyk enabled auto-merge March 10, 2026 00:35
@busbyk busbyk added this pull request to the merge queue Mar 10, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 10, 2026
@busbyk busbyk added this pull request to the merge queue Mar 10, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 10, 2026
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.

Add live page button to Posts

2 participants