Skip to content

Instantly share code, notes, and snippets.

@paulphys
Created September 6, 2020 18:55
Show Gist options
  • Save paulphys/9d1f66a4b854ccafccc1eba4c4b5740b to your computer and use it in GitHub Desktop.
Save paulphys/9d1f66a4b854ccafccc1eba4c4b5740b to your computer and use it in GitHub Desktop.
robots.txt for typescript react
// directory: pages/robots.txt.tsx
import React from 'react';
const getRobots = () => `User-agent: *
Disallow: /
`;
class Sitemap extends React.Component {
public static async getInitialProps({res}:{ res:any }) {
res.setHeader('Content-Type', 'text/plain');
res.write(getRobots());
res.end();
}
}
export default Sitemap;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment