summaryrefslogtreecommitdiffstats
path: root/lib/models/page.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/models/page.js')
-rw-r--r--lib/models/page.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/models/page.js b/lib/models/page.js
index 1b0e9f8..3f54f43 100644
--- a/lib/models/page.js
+++ b/lib/models/page.js
@@ -1,4 +1,5 @@
var Immutable = require('immutable');
+var matter = require('gray-matter');
var File = require('./file');
@@ -32,6 +33,21 @@ Page.prototype.getDir = function() {
};
/**
+ * Return page as text
+ * @return {String}
+*/
+Page.prototype.toText = function() {
+ var attrs = this.getAttributes();
+ var content = this.getContent();
+
+ if (attrs.size === 0) {
+ return content;
+ }
+
+ return matter.stringify(content, attrs.toJS());
+};
+
+/**
* Return path of the page
* @return {String}
*/