Skip to content

Commit fc942fd

Browse files
committed
Hooks for summary data
1 parent 5200454 commit fc942fd

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

lib/generate/index.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,31 @@ var generateBook = function(options) {
271271

272272
// Get summary
273273
.then(function() {
274-
return fs.readFile(path.join(options.input, "SUMMARY.md"), "utf-8")
275-
.then(function(_summary) {
276-
options.summary = parse.summary(_summary);
274+
var summary = {
275+
path: path.join(options.input, "SUMMARY.md")
276+
};
277277

278-
// Parse navigation
279-
options.navigation = parse.navigation(options.summary);
280-
});
278+
var _callHook = function(name) {
279+
return generator.callHook(name, summary)
280+
.then(function(_summary) {
281+
summary = _summary;
282+
return summary;
283+
});
284+
};
285+
286+
return fs.readFile(summary.path, "utf-8")
287+
.then(function(_content) {
288+
summary.content = _content;
289+
return _callHook("summary:before");
290+
})
291+
.then(function() {
292+
summary.content = parse.summary(summary.content);
293+
return _callHook("summary:after");
294+
})
295+
.then(function() {
296+
options.summary = summary.content;
297+
options.navigation = parse.navigation(options.summary);
298+
})
281299
})
282300

283301
// Skip processing some files

0 commit comments

Comments
 (0)