summaryrefslogtreecommitdiffstats
path: root/lib/json/encodePage.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/json/encodePage.js')
-rw-r--r--lib/json/encodePage.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/json/encodePage.js b/lib/json/encodePage.js
new file mode 100644
index 0000000..d876c78
--- /dev/null
+++ b/lib/json/encodePage.js
@@ -0,0 +1,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;