From 70d674d1d8fdc688b58b0dfa7a5560b90daf630c Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Fri, 5 Feb 2021 23:58:18 -0500 Subject: [PATCH] feat: update robots.txt to also be auto-generated --- pages/robots.txt.tsx | 14 ++++++++++++++ public/robots.txt | 2 -- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 pages/robots.txt.tsx delete mode 100644 public/robots.txt diff --git a/pages/robots.txt.tsx b/pages/robots.txt.tsx new file mode 100644 index 0000000..cf85d6a --- /dev/null +++ b/pages/robots.txt.tsx @@ -0,0 +1,14 @@ +import React from 'react' + +import { host } from 'lib/config' + +export default class Robots extends React.Component { + static async getInitialProps({ res }) { + res.setHeader('Content-Type', 'text/plain') + res.write(`User-agent: * +Allow: / +Sitemap: ${host}/sitemap.xml +`) + res.end() + } +} diff --git a/public/robots.txt b/public/robots.txt deleted file mode 100644 index 14267e9..0000000 --- a/public/robots.txt +++ /dev/null @@ -1,2 +0,0 @@ -User-agent: * -Allow: / \ No newline at end of file