Pull out and test `chooseTemplate` function

There was a function in `generate-site-dir.js` that did the work of
picking which template name goes with which pages. I've pulled that
functionality into its own file so it can be better tested & maintained
independently.