Skip to content

fix(blog): enable "See preview" when the blog app omits pageSlug - #7150

Merged
danielfurt merged 1 commit into
mainfrom
danielfurt/blog-preview-button-disabled
Sep 10, 2026
Merged

danielfurt merged 1 commit into
mainfrom
danielfurt/blog-preview-button-disabled

Conversation

@danielfurt

@danielfurt danielfurt commented Sep 10, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The "See preview" button in the blog post/category editor stayed permanently disabled for blogs generated via blog-manager (repro'd on the bagaggio org). Root cause: the button is gated on a computed previewUrl, which was always null because findBlogPageSlug/findBlogCategorySlug only read the blog app block's pageSlug/categorySlug props — and those props are optional with no upstream default, so real sites (bagaggio included) never set them. The blog app block is literally {"__resolveType":"site/apps/deco/blog.ts"}.

The actual post/category routes don't live on the app block — they're decofile Page blocks (website/pages/Page.tsx with a path, e.g. /blog/:slug, /blog/categoria/:categoria). The preview logic simply wasn't looking there.

Fix

In blog-preview-url.ts, when the blog app omits pageSlug/categorySlug, fall back to the decofile Page blocks:

  • Detect the blog post page by the BlogPostPage full-page section marker and the category page by BlogCategoryPage (markers chosen so they never cross-match the BlogPostSeo/BlogCategoryHeader body sections).
  • Pick the fewest-param candidate, so a paginated variant (.../page/:page) never shadows the canonical route.
  • Accept the pt-BR :categoria param used by real sites (bagaggio's category route is /blog/categoria/:categoria).
  • The app prop, when present, still wins — no regression.

Testing

  • bun test .../blog-preview-url.test.ts → 34 pass. Added coverage for: Page-block fallback for post & category, app-prop precedence, paginated-variant disambiguation, negative cross-match (category page ≠ post page), pt-BR :categoria substitution, and an end-to-end buildBlogPostPreviewUrl from a Page block — all using the real bagaggio decofile shapes.
  • Full blog folder suite → 209 pass. tsc --noEmit, oxlint, biome all clean.

Notes / out of scope

  • The preview origin is still lifecycle.previewUrl (the sandbox dev server). If the sandbox/preview is down, the button correctly stays disabled — that's a separate concern from route resolution.
  • The disabled button communicates its reason only via a native title attribute, which barely surfaces. Converting it to the design-system Tooltip is a worthwhile follow-up but left out to keep this PR focused on the root cause.

🤖 Generated with Claude Code


Summary by cubic

Fixes the blog "See preview" button staying disabled when the blog app omits pageSlug/categorySlug. The preview route now falls back to the decofile Page block that contains the blog post or category page; the app prop still wins when present.

  • Detects the post/category page by its full-page section marker and picks the fewest-param route so paginated variants don't shadow the canonical one.
  • Accepts the pt-BR :categoria param used by real sites.
  • The button still stays disabled when the preview sandbox is down; that's a separate concern.

Written for commit db77fc9. Summary will update on new commits.

Review in cubic

The "See preview" button stayed disabled for blogs generated via
blog-manager: the blog app block (`site/apps/deco/blog.ts`) carries no
`pageSlug`/`categorySlug` — those props are optional with no upstream
default — so `findBlogPageSlug` returned null and the preview URL could
never be built.

The real post/category routes live in decofile Page blocks
(`website/pages/Page.tsx` with a `path`), not on the app block. When the
app omits the route props, fall back to those Page blocks: detect the
post/category page by its full-page section marker (`BlogPostPage` /
`BlogCategoryPage`) and pick the fewest-param match so a paginated
variant (`.../page/:page`) never shadows the canonical route. Also
accept the pt-BR `:categoria` param used by real sites. The app prop,
when present, still wins.

Covered with tests using the real bagaggio decofile shapes.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@github-actions github-actions Bot added the claude PR authored by a coding agent label Sep 10, 2026
@danielfurt
danielfurt merged commit ecd52b4 into main Sep 10, 2026
34 checks passed
@danielfurt
danielfurt deleted the danielfurt/blog-preview-button-disabled branch September 10, 2026 22:14
decocms Bot pushed a commit that referenced this pull request Sep 10, 2026
PR: #7150 fix(blog): enable "See preview" when the blog app omits pageSlug
Bump type: patch

- decocms (apps/api/package.json): 4.351.3 -> 4.351.4
- @decocms/native (apps/native/package.json): 4.351.3 -> 4.351.4

Deploy-Scope: web
yuriassuncx added a commit that referenced this pull request Sep 11, 2026
#7150 fixed previewUrl resolution (Page-block fallback when the blog
app has no pageSlug/categorySlug) but the button stayed disabled for
posts still missing Title/Excerpt/Cover image — fields that have
nothing to do with whether the URL can be opened.

`disabled={!previewUrl || hasErrors}` conflated two different
questions: "can we build a working preview link" (slug + category —
already enforced inside buildBlogPostPreviewUrl/applyBlogPageSlug,
which return null when either is missing) and "is this post
publish-ready" (all 5 fields via missingPostFields, used to gate the
Published toggle). Preview only needs the former: a draft with no
excerpt/cover image still renders at its URL.

`disabled={!previewUrl}` alone already captures the real precondition.
The "N problema(s)" badge (still gated on hasErrors, unchanged) keeps
warning about missing publish fields — this only stops it from also
blocking the unrelated preview button.

Co-authored-by: Claude Sonnet 5 <[email protected]>
yuriassuncx added a commit that referenced this pull request Sep 11, 2026
…earch schemas (#7154)

#7151 added contentCollection/contentItem read + selection logic in
ContentBrowser (Blog Manager's "Editar no Studio" deep-link), but
neither the unified-chat route nor the agents route validateSearch
schema declared them. TanStack Router strips any search param a
route's validateSearch doesn't declare before the component ever sees
it via useSearch — so the redirect landed on an empty content editor
instead of the selected post, reproducing exactly what #7151 was
meant to fix.

Factor the content-editor search params (storefront "." deep-link +
Blog Manager deep-link) into one `content-search-params.ts` module
spread into both route schemas, so a future param ContentBrowser reads
can't silently be dropped by one route and not the other again.

The reported "Ver visualização" preview button issue was already
fixed on main by #7150 (route derivation) + #7152 (stop gating on
unrelated fields) earlier today — not reproducible against current
main, just not yet deployed to studio.decocms.com.

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
aka-sacci-ccr pushed a commit that referenced this pull request Sep 11, 2026
One conflict, in the post editor, and it was the interesting kind: both
sides had rewritten the same header.

The restructure moved the header block below a floating expand/close
cluster; upstream changed what's inside it. Kept the restructure's layout
and applied upstream's two behaviour changes into it, because taking
either side whole would have silently dropped a fix:

- #7152 ungated "See preview" from `hasErrors`. The restructure's copy
  still had `disabled={!previewUrl || hasErrors}`, which is the bug that
  PR fixes, so the gate is gone and the title no longer branches on it.
- #7147 gave `useAutosave` an `isSaving` option so overlapping autosaves
  stop dropping the penultimate edit. Threaded through, keeping
  `buildPostBlock` and the three-value destructure the restructure needs
  for `syncPost` on a block rename.

#7150's preview-route fix needed nothing here: the call site is identical
on both sides and the change lives in `buildBlogPostPreviewUrl`.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude PR authored by a coding agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant