33 lines
1007 B
JavaScript
33 lines
1007 B
JavaScript
"use strict";
|
|
/**
|
|
Encode a SummaryArticle to JSON
|
|
|
|
@param {SummaryArticle}
|
|
@return {Object}
|
|
*/
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const encodeSummaryArticleWithCache_1 = __importDefault(require("./encodeSummaryArticleWithCache"));
|
|
function encodeSummaryArticle(article, recursive) {
|
|
let articles = undefined;
|
|
if (recursive !== false) {
|
|
articles = article
|
|
.getArticles()
|
|
.map((article) => (0, encodeSummaryArticleWithCache_1.default)(article))
|
|
.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
|
|
};
|
|
}
|
|
exports.default = encodeSummaryArticle;
|