Skip to content

Commit

Permalink
generate robots.txt (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi authored Sep 19, 2023
1 parent 0416727 commit 777bc05
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
24 changes: 24 additions & 0 deletions packages/ui/fe-bundle/src/pages/[host]/robots.txt.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { GetServerSideProps } from "next";

function RobotsTXT(): void {
// getServerSideProps will do the heavy lifting
}

export default RobotsTXT;

export const getServerSideProps: GetServerSideProps = async ({ params = {}, res }) => {
const host = params.host as string | undefined;

if (host == null) {
throw new Error("host is not defined");
}
const hostWithoutTrailingSlash = host.endsWith("/") ? host.slice(0, -1) : host;

res.write(`User-Agent: *
Sitemap: ${hostWithoutTrailingSlash}/sitemap.xml`);
res.end();

return {
props: {},
};
};
6 changes: 0 additions & 6 deletions packages/ui/fe-bundle/src/pages/[host]/sitemap.xml.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ import { GetServerSideProps } from "next";
import { REGISTRY_SERVICE } from "../../service";
import { getPathsToRevalidate } from "../../utils/revalidation/getPathsToRevalidate";

export declare namespace Sitemap {
export interface Props {
urls: string[];
}
}

function SiteMap(): void {
// getServerSideProps will do the heavy lifting
}
Expand Down

1 comment on commit 777bc05

@vercel
Copy link

@vercel vercel bot commented on 777bc05 Sep 19, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

fern-dev – ./packages/ui/fe-bundle

fern-dev-git-main-buildwithfern.vercel.app
app-dev.buildwithfern.com
fern-dev-buildwithfern.vercel.app
devtest.buildwithfern.com

Please sign in to comment.