diff options
-rw-r--r-- | CHANGES.md | 1 | ||||
-rw-r--r-- | docs/variables.md | 8 | ||||
-rw-r--r-- | lib/backbone/langs.js | 16 | ||||
-rw-r--r-- | lib/output/base.js | 1 | ||||
-rw-r--r-- | lib/page/index.js | 1 |
5 files changed, 27 insertions, 0 deletions
@@ -12,6 +12,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - `pdf.headerTemplate` and `pdf.footerTemplate` have been replaced by a template in theme/book: `_layout/ebook/pdf_header.html` and `_layout/ebook/pdf_footer.html` - Markdown parser is now using CommonMark - Root folder for the book can be specified in a `.gitbook` file +- Multi-lingual books share assets folder ## 2.6.7 - Fix bug with filenames including spaces diff --git a/docs/variables.md b/docs/variables.md index aaa9601..879c646 100644 --- a/docs/variables.md +++ b/docs/variables.md @@ -11,6 +11,7 @@ The following is a reference of the available data during book's parsing and the | `page` | Current page specific information | | `file` | File associated with the current page specific information | | `summary` | Information about the table of contents | +| `languages` | List of languages for multi-lingual books | | `config` | Dump of the `book.json` | ### Book Variables @@ -53,3 +54,10 @@ Thw whole table of contents (`SUMMARY.md`) can be accessed: `summary.parts[0].articles[0].title` will return the title of the first article. +#### Multi-lingual book Variable + +| Variable | Description | +| -------- | ----------- | +| `languages.list` | List of languages for this book | + +Languages are defined by `{ id: 'en', title: 'English' }`. diff --git a/lib/backbone/langs.js b/lib/backbone/langs.js index a40bd80..e339fa9 100644 --- a/lib/backbone/langs.js +++ b/lib/backbone/langs.js @@ -62,4 +62,20 @@ Langs.prototype.count = function() { return _.size(this.languages); }; +// Return templating context for the languages list +Langs.prototype.getContext = function() { + if (this.count() == 0) return {}; + + return { + languages: { + list: _.map(this.languages, function(lang) { + return { + id: lang.id, + title: lang.title + }; + }) + } + }; +}; + module.exports = Langs; diff --git a/lib/output/base.js b/lib/output/base.js index 77c2d9f..fb0adca 100644 --- a/lib/output/base.js +++ b/lib/output/base.js @@ -202,6 +202,7 @@ Output.prototype.getContext = function() { return _.extend( {}, this.book.getContext(), + this.book.langs.getContext(), this.book.summary.getContext(), this.book.glossary.getContext(), this.book.config.getContext() diff --git a/lib/page/index.js b/lib/page/index.js index 45b3598..b512ff4 100644 --- a/lib/page/index.js +++ b/lib/page/index.js @@ -128,6 +128,7 @@ Page.prototype.getContext = function() { }, gitbook.getContext(), this.book.getContext(), + this.book.langs.getContext(), this.book.summary.getContext(), this.book.glossary.getContext(), this.book.config.getContext() |