Update React Editor integration and clean up template

This commit is contained in:
Rami Bitar
2026-08-15 13:47:33 -04:00
parent 0a7ea0bf6b
commit 0fb6cef226
82 changed files with 113 additions and 913 deletions
+1 -11
View File
@@ -1,7 +1,6 @@
import type { Metadata } from 'next';
import { site } from '@/config/site';
/** The subset of root props (see config/root.tsx) that describes a page. */
interface EditorPage {
root?: {
props?: {
@@ -16,25 +15,16 @@ interface MetadataOverrides {
title?: string;
description?: string;
image?: string;
/** Root-relative path, used for the canonical and og:url. */
path?: string;
}
/**
* Turns a page.json's root props into Next metadata. The editor exposes
* title/description/ogImage on the root, so editing a page in the editor is
* what changes its tags; `overrides` lets dynamic routes layer fetched product,
* collection or policy data on top.
*/
export function pageMetadata(
page: EditorPage,
overrides: MetadataOverrides = {}
): Metadata {
const props = page.root?.props ?? {};
// Editor-authored titles already carry the brand ("About — Shop"), so they
// opt out of the root template with `absolute`. A fetched override is a bare
// product or collection name and flows through the template instead.
// Editor titles already include the brand; fetched titles use the template.
const title = overrides.title ?? props.title ?? site.storeName;
const socialTitle = overrides.title ? `${title} — ${site.storeName}` : title;
const description =