mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-17 08:05:19 +00:00
31 lines
638 B
JavaScript
31 lines
638 B
JavaScript
/**
|
|
Return a JSON representation of a page
|
|
|
|
@param {Page} page
|
|
@param {Summary} summary
|
|
@return {Object}
|
|
*/
|
|
function encodePage(page, summary) {
|
|
var file = page.getFile();
|
|
var attributes = page.getAttributes();
|
|
var article = summary.getByPath(file.getPath());
|
|
|
|
|
|
var result = attributes.toJS();
|
|
|
|
if (article) {
|
|
result.title = article.getTitle();
|
|
result.level = article.getLevel();
|
|
result.depth = article.getDepth();
|
|
|
|
// todo: next and prev
|
|
}
|
|
|
|
result.content = page.getContent();
|
|
result.dir = page.getDir();
|
|
|
|
return result;
|
|
}
|
|
|
|
module.exports = encodePage;
|