Skip to content

Commit 44f0ec0

Browse files
committed
✨ add robots.txt
1 parent 0b4e303 commit 44f0ec0

4 files changed

Lines changed: 16 additions & 1 deletion

File tree

build/rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const config = {
3434
}
3535
}),
3636
rawContentPlugin({
37-
include: '**.css',
37+
include: ['**.css', '**.txt'],
3838
}),
3939
typescript(),
4040
etaPlugin({

src/robots.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
User-agent: *
2+
Allow: /

src/router.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import renderNotFound from './templates/404.eta'
66
import renderError from './templates/error.eta'
77
import renderHome from './templates/home.eta'
88

9+
import robotsTxt from './robots.txt'
10+
911
export const router = new Router({
1012
ignoreTrailingSlash: true,
1113
defaultRoute (req) {
@@ -18,6 +20,12 @@ export const router = new Router({
1820
}
1921
})
2022

23+
router.get('/robots.txt', () => new Response(robotsTxt, {
24+
headers: {
25+
'Content-Type': 'text/plain; charset=utf-8'
26+
}
27+
}))
28+
2129
router.get('/_assets/style.css', () => new Response(styleCss, {
2230
headers: {
2331
'Content-Type': 'text/css; charset=utf-8'

src/typings/mock.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ declare module '*.css' {
22
declare const content: string
33
export default content
44
}
5+
6+
declare module '*.txt' {
7+
declare const content: string
8+
export default content
9+
}

0 commit comments

Comments
 (0)