Skip to content

Commit

Permalink
Rename Robots Txt
Browse files Browse the repository at this point in the history
  • Loading branch information
koechkevin committed Jul 10, 2024
1 parent 2d2d0df commit 81e0fcb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion apps/roboshield/payload-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export interface Page {
fetch: string;
id?: string | null;
blockName?: string | null;
blockType: "existing-robots";
blockType: "existing-robots-txt";
}
| {
title: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type Props = { [key: string]: string } & {
title: string;
hint?: Children;
blockType:
| "existing-robots"
| "existing-robots-txt"
| "delays"
| "paths"
| "block-bots"
Expand All @@ -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,
Expand Down Expand Up @@ -95,7 +95,7 @@ const RobotsGenerator: FC<Props> = React.forwardRef(
}, [state]);

const activeStepSlug:
| "existing-robots"
| "existing-robots-txt"
| "delays"
| "paths"
| "block-bots"
Expand Down
11 changes: 9 additions & 2 deletions apps/roboshield/src/payload/blocks/RobotsTxtGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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",
Expand Down

0 comments on commit 81e0fcb

Please sign in to comment.