diff --git a/apps/roboshield/src/pages/about.tsx b/apps/roboshield/src/pages/[[...slug]].tsx similarity index 90% rename from apps/roboshield/src/pages/about.tsx rename to apps/roboshield/src/pages/[[...slug]].tsx index 7f2f62036..0e3b365ed 100644 --- a/apps/roboshield/src/pages/about.tsx +++ b/apps/roboshield/src/pages/[[...slug]].tsx @@ -3,7 +3,7 @@ import BlockRenderer from "@/roboshield/components/BlockRenderer"; import { PageProps } from "@/roboshield/lib/data"; import { GetServerSidePropsContext } from "next"; -export default function About({ blocks }: PageProps) { +export default function Page({ blocks }: PageProps) { return ( <> diff --git a/apps/roboshield/src/pages/index.tsx b/apps/roboshield/src/pages/index.tsx deleted file mode 100644 index 362f300ca..000000000 --- a/apps/roboshield/src/pages/index.tsx +++ /dev/null @@ -1,227 +0,0 @@ -import { Section } from "@commons-ui/core"; -import { - IconButton, - Alert, - Box, - Paper, - Stack, - Step, - StepButton, - Stepper, - Tooltip, -} from "@mui/material"; -import { useEffect } from "react"; -import React from "react"; -import { useRef, useState } from "react"; - -import Delays from "@/roboshield/components/Delays"; -import Hero from "@/roboshield/components/Hero"; -import Sitemaps from "@/roboshield/components/Sitemaps"; - -import CommonBots from "@/roboshield/components/CommonBots"; -import CommonSettings from "@/roboshield/components/CommonSettings"; -import ExistingRobots from "@/roboshield/components/ExistingRobots"; -import Finish from "@/roboshield/components/Finish"; -import { - useGlobalState, - defaultState, -} from "@/roboshield/context/GlobalContext"; -import { generateRobots } from "@/roboshield/lib/robots"; -import { getPageServerSideProps } from "@/roboshield/lib/data"; - -interface Step { - label: string; - description: string; - component: React.FC; -} - -export default function Home() { - const [activeStep, setActiveStep] = useState(0); - const { state, setState } = useGlobalState(); - const [code, setCode] = useState(state.robots || ""); - const scrolRef = useRef(null); - - const steps: Step[] = [ - { - label: "Existing robots", - description: `Start by fetching the robots.txt file of the website you want to generate robots for.`, - component: ExistingRobots, - }, - { - label: "Delays", - description: `You can set bot delays for the robots you want to generate.`, - component: Delays, - }, - { - label: "Paths", - description: - "You can set disallowed and allowed paths for the robots you want to generate. All paths should be relative to the root of your site and end with a /", - component: CommonSettings, - }, - { - label: "Block Bots", - description: `Select bots you want to block from crawling your website.`, - component: CommonBots, - }, - { - label: "Site Maps", - description: `You can add sitemap URLs to your robots.txt file.`, - component: Sitemaps, - }, - { - label: "Finish", - description: `Your robots.txt file has been generated successfully. You can now copy the code or download the file.`, - component: Finish, - }, - ]; - - const handleNext = () => { - setActiveStep((prevActiveStep) => prevActiveStep + 1); - }; - - const handleBack = () => { - setActiveStep((prevActiveStep) => prevActiveStep - 1); - }; - - const handleReset = () => { - setState(defaultState); - setActiveStep(0); - }; - - const handleNextStep = (data: any) => { - const newState = { ...state, ...data }; - setState(newState); - handleNext(); - }; - - const handleSkipToLast = (data: any) => { - const newState = { ...state, ...data }; - setState(newState); - setActiveStep(steps.length - 1); - }; - - const handleStep = (step: number) => () => { - setActiveStep(step); - }; - - useEffect(() => { - const generateRobotsFile = async () => { - const robots = await generateRobots(state); - setCode(robots); - }; - - generateRobotsFile(); - }, [state]); - - const ActiveComponent = steps[activeStep]?.component ?? null; - - return ( - <> - -
- - - - - - - - {steps.map((step, index) => ( - - - {step.label} - - - ))} - - {ActiveComponent && ( - - - - )} - - - - -
- - ); -} - -export async function getServerSideProps(context: any) { - return getPageServerSideProps(context); -}