~/blog/building-a-terminal-website.md
Building a website you can cd into
The terminal on this site isn’t a real shell — it’s about 500 lines of TypeScript pretending very hard.
The trick: a build-time index
At build time Astro reads every post and project and produces a small JSON index. The terminal turns that index into a virtual filesystem:
~/
├── about.md
├── contact.txt
├── blog/
│ └── hello-world.md
└── projects/
├── hardware/
└── software/
No server, no API — ls and cat just walk an object tree.
Commands are plain objects
Each command is a tiny module with a name, a help line and a run function that returns lines of text and optional actions (navigate, change theme, launch a game…):
export const whoami: Command = {
name: 'whoami',
help: 'print the user behind this site',
run: (_args, ctx) => ({ lines: [[{ text: ctx.index.profile.name }]] }),
};
That keeps the engine pure and easy to unit test — the React component just renders whatever comes back.
Things I’d add next
- Pipes (
ls | grep), because why not. - A
manpage for every command. - More secrets. Obviously.
Key takeaways
Keep the fun parts optional: every page still works without JavaScript.