index.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. module.exports = {
  2. book: {
  3. assets: "./book",
  4. js: [
  5. "test.js"
  6. ],
  7. css: [
  8. "test.css"
  9. ],
  10. html: {
  11. "html:start": function() {
  12. return "<!-- Start book "+this.options.title+" -->"
  13. },
  14. "html:end": function() {
  15. return "<!-- End of book "+this.options.title+" -->"
  16. },
  17. "head:start": "<!-- head:start -->",
  18. "head:end": "<!-- head:end -->",
  19. "body:start": "<!-- body:start -->",
  20. "body:end": "<!-- body:end -->"
  21. }
  22. },
  23. hooks: {
  24. // For all the hooks, this represent the current generator
  25. // This is called before the book is generated
  26. "init": function() {
  27. console.log("init!");
  28. },
  29. // This is called after the book generation
  30. "finish": function() {
  31. console.log("finish!");
  32. },
  33. // The following hooks are called for each page of the book
  34. // and can be used to change page content (html, data or markdown)
  35. // Before parsing markdown
  36. "page:before": function(page) {
  37. // page.path is the path to the file
  38. // page.content is a string with the file markdown content
  39. // Example:
  40. //page.content = "# Title\n" + page.content;
  41. return page;
  42. },
  43. // Before html generation
  44. "page": function(page) {
  45. // page.path is the path to the file
  46. // page.sections is a list of parsed sections
  47. // Example:
  48. //page.sections.unshift({type: "normal", content: "<h1>Title</h1>"})
  49. return page;
  50. },
  51. // After html generation
  52. "page:after": function(page) {
  53. // page.path is the path to the file
  54. // page.content is a string with the html output
  55. // Example:
  56. //page.content = "<h1>Title</h1>\n" + page.content;
  57. // -> This title will be added before the html tag so not visible in the browser
  58. return page;
  59. }
  60. }
  61. };