Skip to content

[nextjs][content] Support time-based preview in editing render endpoint#524

Merged
illiakovalenko merged 9 commits into
devfrom
feature/JSS-9801-support-time-based-preview
Jun 19, 2026
Merged

[nextjs][content] Support time-based preview in editing render endpoint#524
illiakovalenko merged 9 commits into
devfrom
feature/JSS-9801-support-time-based-preview

Conversation

@sc-shakyawijerathne

Copy link
Copy Markdown
Contributor

Description / Motivation

This PR adds support for calendar-based preview in the JSS editing render endpoint. The editing middleware now accepts an optional sc_previewTime query parameter and forwards it as a header to Edge Preview GraphQL.

This enables XM Cloud Pages users to preview content at specific future dates, allowing validation of scheduled content changes before they go live.

Testing Details

  • Unit Test Added
  • Manual Test/Other (Please elaborate)

Unit Tests:

  • Test that sc_previewTime query param is forwarded as header
  • Test backward compatibility when sc_previewTime is absent

Manual Testing:

  • Verified local editing render endpoint accepts sc_previewTime parameter
  • Confirmed header is correctly forwarded to GraphQL requests

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

@changeset-bot

changeset-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0ef3b03

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@sitecore-content-sdk/nextjs Patch
@sitecore-content-sdk/content Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

📦 Package Size and Test Coverage Report

Package Base Size PR Size Δ Change Base Coverage PR Coverage Δ Change
analytics-core 67.34 KB 67.34 KB ✅ 0.00 KB 97.40% 97.40% 0.00%
cli 61.06 KB 61.06 KB ✅ 0.00 KB 71.36% 71.36% 0.00%
content 432.56 KB 432.99 KB 🔺 +0.43 KB 92.45% 92.46% +0.01%
core 120.61 KB 120.61 KB ✅ 0.00 KB 91.27% 91.27% 0.00%
create-content-sdk-app 535.58 KB 535.58 KB ✅ 0.00 KB 96.47% 96.47% 0.00%
events 72.27 KB 72.27 KB ✅ 0.00 KB 97.97% 97.97% 0.00%
nextjs 566.34 KB 566.30 KB 🔻 -0.04 KB 90.98% 90.99% +0.00%
personalize 64.01 KB 64.01 KB ✅ 0.00 KB 99.74% 99.74% 0.00%
react 232.23 KB 232.23 KB ✅ 0.00 KB 94.00% 94.00% 0.00%
search 8.10 KB 8.10 KB ✅ 0.00 KB 98.57% 98.57% 0.00%
Total 🔺 +0.39 KB

@illiakovalenko illiakovalenko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good 👍
Please, see a couple of comments below

[EDITING_PARAMS_HEADER]: JSON.stringify(previewData),
};

if (query.sc_previewTime) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We have mapEditingParams method, you can map this parameter there

sc_layoutKind?: LayoutKind;
sc_variant?: string;
sc_version?: string;
sc_previewTime?: string;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The new parameter needs to be passed to EditingService.fetchEditingData, so that it is included in the layout request.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It should be set as a sc_previewTime header

[EDITING_PARAMS_HEADER]: JSON.stringify(previewData),
};

if (query.sc_previewTime) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Also, keep in mind that we have editing-render-route-handler - App Router. You, probably, shouldn't need to make any additional changes there, as updating the mapEditingParams method should apply this automatically. Probably only unit tests

Comment thread packages/nextjs/src/editing/utils.ts Outdated
dataSourceId: query.dataSourceId,
version: query.sc_version,
generation: query.generation,
...(query.sc_previewTime && { previewTime: query.sc_previewTime }),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In design studio we don't expect to pass it, so let's remove it. We need to support it only for Sitecore Pages

mode,
site,
variantId,
...(previewTime && { previewTime }),

@illiakovalenko illiakovalenko Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we simplify it a bit?

Suggested change
...(previewTime && { previewTime }),
previewTime,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's add unit tests to cover new parameter

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's update unit tests

@sc-shakyawijerathne sc-shakyawijerathne requested review from illiakovalenko and removed request for illiakovalenko June 19, 2026 11:52

@illiakovalenko illiakovalenko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks great! 👍

Comment thread packages/nextjs/src/editing/utils.ts
@illiakovalenko illiakovalenko force-pushed the feature/JSS-9801-support-time-based-preview branch from 9ebc7bd to 0ef3b03 Compare June 19, 2026 13:20
@illiakovalenko illiakovalenko merged commit 7b3b3f3 into dev Jun 19, 2026
7 checks passed
@illiakovalenko illiakovalenko deleted the feature/JSS-9801-support-time-based-preview branch June 19, 2026 13:28
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.

2 participants