Use a file task for book:table_of_contents

The file task lets rake know a file is being built so it can rebuild it
when stale or missing.  Also, declare a dependency on _data/pages.yml so
the table of contents is rebuilt when new pages are added.
Use File.write over File.open with block
Move file task after regular tasks

This lets us see ordering better.
Use imported dependencies to create pages

This pushes down the responsibility of creating a page to a method that
is invoked from a task.  All the wirings are made so you could create
special pages that get built automatically when things change.
Use directory task instead of mkdir
Rebuild pages when _config.yml changes
Ignore .depends.rf as it is autogenerated