diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-07-11 17:13:40 -0700 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-07-11 17:13:40 -0700 |
commit | 7a47049367738a86b94f266056c95f812c17d5aa (patch) | |
tree | b9f72e74e81be0febb6990bc597c60f4b1d5ab8b | |
parent | a9f473260cdbf7944a8d95c4292a93897f9210eb (diff) | |
parent | fc942fdeca9264d2476eb8bcb576c454eff88055 (diff) | |
download | gitbook-7a47049367738a86b94f266056c95f812c17d5aa.zip gitbook-7a47049367738a86b94f266056c95f812c17d5aa.tar.gz gitbook-7a47049367738a86b94f266056c95f812c17d5aa.tar.bz2 |
Merge pull request #354 from citizenmatt/summary_hooks
Plugin hooks for summary data
-rw-r--r-- | lib/generate/index.js | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/lib/generate/index.js b/lib/generate/index.js index 444f75f..53de646 100644 --- a/lib/generate/index.js +++ b/lib/generate/index.js @@ -271,13 +271,31 @@ var generateBook = function(options) { // Get summary .then(function() { - return fs.readFile(path.join(options.input, "SUMMARY.md"), "utf-8") - .then(function(_summary) { - options.summary = parse.summary(_summary); + var summary = { + path: path.join(options.input, "SUMMARY.md") + }; - // Parse navigation - options.navigation = parse.navigation(options.summary); - }); + var _callHook = function(name) { + return generator.callHook(name, summary) + .then(function(_summary) { + summary = _summary; + return summary; + }); + }; + + return fs.readFile(summary.path, "utf-8") + .then(function(_content) { + summary.content = _content; + return _callHook("summary:before"); + }) + .then(function() { + summary.content = parse.summary(summary.content); + return _callHook("summary:after"); + }) + .then(function() { + options.summary = summary.content; + options.navigation = parse.navigation(options.summary); + }) }) // Skip processing some files |