blob: d876c784e4dadca2a9b8487203ee94ea5a2e5e3c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
/**
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;
|