@wocart/theme / astro / previewTarget
Function: previewTarget()
previewTarget(
theme,draft,client):Promise<PreviewTarget>
What an editor's preview of draft renders, or null — answer 404 — for a
surface the theme does not declare:
- A template previews the resource the draft's
pathnames (/products/robe), else the store's first product, category, default collection or text page. A store with none still previews:paramsis empty and the template renders empty, so its sections can be arranged. - An area (the header, the footer) previews on the page its
pathnames when the theme composes that page, else on the home page. - The resource is chosen by the surface's
pageType, never its key, so an alternate (product.compact) previews like its base. - A landing page's own document (
lp:<id>) previews with the theme'slandingsurface on the page itspathnames (/lp/<slug>), and the target keeps its own surface, so the sections render that page's document.
Code
Parameters
theme
draft
PreviewDraft
client
cart
CartNamespace
categories
CategoriesNamespace
collections
CollectionsNamespace
config
ConfigNamespace
geo
GeoNamespace
menus
MenusNamespace
orders
OrdersNamespace
pageData
PageDataNamespace
pages
PagesNamespace
products
ProductsNamespace
shipping
ShippingNamespace
Returns
Promise<PreviewTarget>