Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions apps/builder/app/builder/features/pages/page-settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ import {
} from "./page-utils";
import { Form } from "./form";
import { CustomMetadata } from "./custom-metadata";
import { SchemaMarkup } from "./schema-markup";

const fieldDefaultValues = {
name: "Untitled",
Expand All @@ -128,6 +129,7 @@ const fieldDefaultValues = {
redirect: `""`,
documentType: "html" as (typeof documentTypes)[number],
customMetas: [{ property: "", content: `""` }],
schemaMarkup: [] as Array<{ type: "application/ld+json"; content: string }>,
marketplaceInclude: false,
marketplaceCategory: "",
marketplaceThumbnailAssetId: "",
Expand Down Expand Up @@ -190,6 +192,14 @@ const SharedPageValues = z.object({
})
)
.optional(),
schemaMarkup: z
.array(
z.object({
type: z.enum(["application/ld+json"]),
content: z.string(),
})
)
.optional(),
});

const HomePageValues = SharedPageValues.extend({
Expand Down Expand Up @@ -284,6 +294,7 @@ const toFormValues = (
documentType: page.meta.documentType ?? fieldDefaultValues.documentType,
isHomePage,
customMetas: page.meta.custom ?? fieldDefaultValues.customMetas,
schemaMarkup: page.meta.schemaMarkup ?? fieldDefaultValues.schemaMarkup,
marketplaceInclude: page.marketplace?.include ?? false,
marketplaceCategory: page.marketplace?.category ?? "",
marketplaceThumbnailAssetId: page.marketplace?.thumbnailAssetId ?? "",
Expand Down Expand Up @@ -1147,6 +1158,31 @@ const FormFields = ({
/>
</div>
</InputErrorsTooltip>

<Separator />

<SchemaMarkup
schemaMarkup={values.schemaMarkup}
onChange={(schemaMarkup) => {
onChange({
field: "schemaMarkup",
value: schemaMarkup,
});
}}
pageContext={{
Copy link
Member

Choose a reason for hiding this comment

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

hmm, you are not providing the entire page content, what am I missing?

Copy link
Author

Choose a reason for hiding this comment

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

Hey @kof !
Yes, i intentionally did not send the entire page content. The same reason you mentioned, the model costs, but if we go with a cheap model we should definitely include the page content for better results, even if the cost concern is actually minimal since schema generation is typically a one-time action per page, not continuous usage.

But regarding the AI integration: Yes, makes sense to merge JSON-LD editing without AI first. I can adapt the PR to remove the AI generation feature and keep just the manual schema editing capability.

Should I update the PR to remove the AI parts?

pageName: values.name,
pageTitle: title,
pageDescription: description || undefined,
siteName: pages?.meta?.siteName || undefined,
siteUrl: pageUrl,
pagePath: values.path,
contactEmail: pages?.meta?.contactEmail || undefined,
language:
String(computeExpression(values.language, variableValues)) ||
undefined,
socialImageUrl: socialImageUrl || undefined,
}}
/>
</fieldset>

{(project?.marketplaceApprovalStatus === "PENDING" ||
Expand Down Expand Up @@ -1373,6 +1409,11 @@ const updatePage = (pageId: Page["id"], values: Partial<Values>) => {
page.meta.custom = values.customMetas;
}

if (values.schemaMarkup !== undefined) {
page.meta.schemaMarkup =
values.schemaMarkup.length > 0 ? values.schemaMarkup : undefined;
}

if (values.documentType !== undefined) {
page.meta.documentType = values.documentType;
}
Expand Down
Loading