I recently wanted to replace my statically generated sitemap.xml file with a dynamically one generated by ghost. It ended up being pretty trivial to do, but the following two links helped immensely. At present, it’s a hack to the core which you’ll have to repeat if you upgrade – but that’s a small price to pay for having your sitemap generated dynamically.
For adding sitemap support:
For updating the format/count: