Skip to content

adminAppearanceSectionPreview

The sections a channel would draw if its staged edits were published: draft content replaces published content, staged status and order are applied, sections that are off are left out, and footer_links stays last.

A headless storefront renders this to show a merchant their unpublished work. The storefront's own sections query never returns staged content, which is why the preview lives on the admin side and needs an admin token.

Arguments

ArgumentTypeDescription
codeString!Theme being previewed.
channelIntChannel being previewed. Falls back to the current channel.
localeStringLocale the content is read in. Falls back to the channel locale.

Fields

FieldTypeDescription
themeCodeStringTheme that was previewed.
channelIdIntChannel that was previewed.
localeStringLocale the content was read in.
sectionsIterableSections in the order they would be drawn, each { id, name, type, sortOrder, status, hasDraft, options }.

Use cases

  • Render an unpublished storefront page — the list is ready to draw in order, each section's content already resolved for the locale.
  • Show what publishing would change — compare each entry's hasDraft against the published adminAppearanceSections.

Best practices

  • Query sections bare. It is a JSON value and takes no sub-selection.
  • Sections staged off do not appear at all — the preview is what shoppers would see, so do not use it to build the editor's list.
  • A section with no staged edits is returned with its published values, so the preview is complete even when only one section was touched.

Permissions

Requires appearance.sections.

Released under the MIT License.