diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-04-06 13:44:14 -0700 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-04-06 13:44:14 -0700 |
commit | 014b2f9c6902235216fee390078ece0049344c0b (patch) | |
tree | 4b7a40abe74cce7b961f8a3bc63da9d4f044b315 /lib/parse | |
parent | fb26b634ce2f332bcc3a8764009bdc65a2245f35 (diff) | |
parent | 65cb23feabb7ae311f18c5f50978686d202dafec (diff) | |
download | gitbook-014b2f9c6902235216fee390078ece0049344c0b.zip gitbook-014b2f9c6902235216fee390078ece0049344c0b.tar.gz gitbook-014b2f9c6902235216fee390078ece0049344c0b.tar.bz2 |
Merge pull request #35 from GitbookIO/feature/multilangs
Fix #34: Feature/multilangs
Diffstat (limited to 'lib/parse')
-rw-r--r-- | lib/parse/index.js | 1 | ||||
-rw-r--r-- | lib/parse/langs.js | 23 |
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/parse/index.js b/lib/parse/index.js index 951e401..ec98347 100644 --- a/lib/parse/index.js +++ b/lib/parse/index.js @@ -1,5 +1,6 @@ module.exports = { summary: require('./summary'), + langs: require('./langs'), page: require('./page'), progress: require('./progress'), navigation: require('./navigation'), diff --git a/lib/parse/langs.js b/lib/parse/langs.js new file mode 100644 index 0000000..46c3a46 --- /dev/null +++ b/lib/parse/langs.js @@ -0,0 +1,23 @@ +var _ = require("lodash") +var parseSummary = require("./summary"); + +var parseLangs = function(content) { + var summary = parseSummary(content); + + return { + list: _.chain(summary.chapters) + .filter(function(entry) { + return entry.path != null; + }) + .map(function(entry) { + return { + title: entry.title, + path: entry.path, + lang: entry.path.replace("/", "") + }; + }) + .value() + } +}; + +module.exports = parseLangs;
\ No newline at end of file |