Press ⌘K (or Ctrl+K) anywhere on my site and you get a search box that jumps to any page, case study, game, blog post or Dota 2 hero. Press ~ and you get a terminal. Neither is essential. Both are the kind of detail that makes a developer's site feel like it was made by a developer.
Here's how they're built, and the few decisions that kept them simple.
Logic first, UI second
Both features are mostly logic, so I wrote the logic as pure functions with no React involved:
buildItems(posts, heroes, work) returns a flat list of { group, label, url, keywords } ;
filterItems(items, query) ranks them;
runCommand(input) returns { lines, action } for the terminal, where action is "navigate", "clear" or "exit";
complete(input) does tab completion.
The React components only render state and call these.…