mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-12 05:48:57 +00:00
29 lines
641 B
JavaScript
29 lines
641 B
JavaScript
|
|
/**
|
|
Encode a SummaryArticle to JSON
|
|
|
|
@param {SummaryArticle}
|
|
@return {Object}
|
|
*/
|
|
function encodeSummaryArticle(article, recursive) {
|
|
var articles = undefined;
|
|
if (recursive !== false) {
|
|
articles = article.getArticles()
|
|
.map(encodeSummaryArticle)
|
|
.toJS();
|
|
}
|
|
|
|
return {
|
|
title: article.getTitle(),
|
|
level: article.getLevel(),
|
|
depth: article.getDepth(),
|
|
anchor: article.getAnchor(),
|
|
url: article.getUrl(),
|
|
path: article.getPath(),
|
|
ref: article.getRef(),
|
|
articles: articles
|
|
};
|
|
}
|
|
|
|
module.exports = encodeSummaryArticle;
|