diff --git a/apps/roboshield/payload-types.ts b/apps/roboshield/payload-types.ts index 25d346789..f7b1d2b82 100644 --- a/apps/roboshield/payload-types.ts +++ b/apps/roboshield/payload-types.ts @@ -125,7 +125,7 @@ export interface Page { fetch: string; id?: string | null; blockName?: string | null; - blockType: "existing-robots"; + blockType: "existing-robots-txt"; } | { title: string; diff --git a/apps/roboshield/src/components/RobotsTxtGenerator/RobotsTxtGenerator.tsx b/apps/roboshield/src/components/RobotsTxtGenerator/RobotsTxtGenerator.tsx index 344e0eb45..63f080fa1 100644 --- a/apps/roboshield/src/components/RobotsTxtGenerator/RobotsTxtGenerator.tsx +++ b/apps/roboshield/src/components/RobotsTxtGenerator/RobotsTxtGenerator.tsx @@ -23,7 +23,7 @@ type Props = { [key: string]: string } & { title: string; hint?: Children; blockType: - | "existing-robots" + | "existing-robots-txt" | "delays" | "paths" | "block-bots" @@ -42,7 +42,7 @@ type Props = { [key: string]: string } & { }; const slugComponentsMap = { - "existing-robots": ExistingRobotsTxt, + "existing-robots-txt": ExistingRobotsTxt, delays: Delays, paths: CommonSettings, "block-bots": CommonBots, @@ -95,7 +95,7 @@ const RobotsGenerator: FC = React.forwardRef( }, [state]); const activeStepSlug: - | "existing-robots" + | "existing-robots-txt" | "delays" | "paths" | "block-bots" diff --git a/apps/roboshield/src/payload/blocks/RobotsTxtGenerator.ts b/apps/roboshield/src/payload/blocks/RobotsTxtGenerator.ts index 8e576bf36..e17695554 100644 --- a/apps/roboshield/src/payload/blocks/RobotsTxtGenerator.ts +++ b/apps/roboshield/src/payload/blocks/RobotsTxtGenerator.ts @@ -13,6 +13,13 @@ const validateSteps: Validate = (value = [], args) => { if (missingSteps.length) { return `The following steps are missing: ${missingSteps.join(", ")}`; } + const robotsTxtBlockIndex = value.findIndex( + ({ blockType }: { blockType: string }) => + blockType === "existing-robots-txt", + ); + if (robotsTxtBlockIndex > 0) { + return "Existing Robots Txt step should appear first"; + } const lastBlock = value[value.length - 1]; if (lastBlock?.blockType !== "finish") { return "Finish Step should appear last"; @@ -21,8 +28,8 @@ const validateSteps: Validate = (value = [], args) => { }; const ExistingRobots: Block = { - slug: "existing-robots", - labels: { singular: "Existing Robots", plural: "Existing Robots" }, + slug: "existing-robots-txt", + labels: { singular: "Existing Robots Txt", plural: "Existing Robots Txt" }, fields: [ { name: "title",