AppView in a box as a Vite plugin thing hatk.dev
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

add default robots.txt and meta description for Lighthouse SEO

Serves a default robots.txt from the hatk package, with user override
via public/robots.txt. Adds meta description to the app.html scaffold
template.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+21
+2
docs/site/src/content/docs/getting-started/project-structure.mdx
··· 167 167 └── index.html 168 168 ``` 169 169 170 + Hatk provides a default `robots.txt` that allows all crawlers. To customize it, add your own `public/robots.txt` — it will take priority over the default. 171 + 170 172 ### `src/` (with `--svelte`) 171 173 172 174 When scaffolded with `--svelte`, a SvelteKit frontend replaces the plain `public/index.html`:
+2
packages/hatk/public/robots.txt
··· 1 + User-agent: * 2 + Allow: /
+1
packages/hatk/src/cli.ts
··· 1103 1103 <head> 1104 1104 <meta charset="utf-8" /> 1105 1105 <meta name="viewport" content="width=device-width, initial-scale=1" /> 1106 + <meta name="description" content="${name}" /> 1106 1107 <title>${name}</title> 1107 1108 %sveltekit.head% 1108 1109 </head>
+16
packages/hatk/src/server.ts
··· 1 1 import { createServer, type Server, type IncomingMessage } from 'node:http' 2 + import { existsSync } from 'node:fs' 2 3 import { readFile } from 'node:fs/promises' 3 4 import { join, extname } from 'node:path' 4 5 import { ··· 977 978 return 978 979 } 979 980 throw err 981 + } 982 + } 983 + 984 + // GET /robots.txt — serve from user's public dir or fall back to hatk default 985 + if (url.pathname === '/robots.txt') { 986 + const userRobots = publicDir ? join(publicDir, 'robots.txt') : null 987 + const defaultRobots = join(import.meta.dirname, '../public/robots.txt') 988 + const robotsPath = userRobots && existsSync(userRobots) ? userRobots : defaultRobots 989 + try { 990 + const content = await readFile(robotsPath) 991 + res.writeHead(200, { 'Content-Type': 'text/plain' }) 992 + res.end(content) 993 + return 994 + } catch { 995 + // fall through 980 996 } 981 997 } 982 998