diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-10-05 23:11:57 +0200 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-10-05 23:12:00 +0200 |
commit | 6ce4949df3cd9101893361ca8e34c4863087f932 (patch) | |
tree | d89e97f1396d6408d0850524483be338450976ff /packages/gitbook/src/json | |
parent | 0614613b8414d62a6150e58f55a53c985a83937c (diff) | |
download | gitbook-6ce4949df3cd9101893361ca8e34c4863087f932.zip gitbook-6ce4949df3cd9101893361ca8e34c4863087f932.tar.gz gitbook-6ce4949df3cd9101893361ca8e34c4863087f932.tar.bz2 |
Add "url" to file
Diffstat (limited to 'packages/gitbook/src/json')
-rw-r--r-- | packages/gitbook/src/json/encodeFile.js | 18 | ||||
-rw-r--r-- | packages/gitbook/src/json/encodeOutputWithPage.js | 4 | ||||
-rw-r--r-- | packages/gitbook/src/json/encodePage.js | 12 |
3 files changed, 19 insertions, 15 deletions
diff --git a/packages/gitbook/src/json/encodeFile.js b/packages/gitbook/src/json/encodeFile.js index 487a74c..1f41228 100644 --- a/packages/gitbook/src/json/encodeFile.js +++ b/packages/gitbook/src/json/encodeFile.js @@ -1,20 +1,22 @@ /** - Return a JSON representation of a file - - @param {File} file - @return {Object} -*/ -function encodeFileToJson(file) { + * Return a JSON representation of a file + * + * @param {File} file + * @param {String} url? + * @return {Object} json + */ +function encodeFileToJson(file, url) { const filePath = file.getPath(); if (!filePath) { return undefined; } return { - path: filePath, + path: filePath, mtime: file.getMTime(), - type: file.getType() + type: file.getType(), + url }; } diff --git a/packages/gitbook/src/json/encodeOutputWithPage.js b/packages/gitbook/src/json/encodeOutputWithPage.js index 58db070..e6cb0c5 100644 --- a/packages/gitbook/src/json/encodeOutputWithPage.js +++ b/packages/gitbook/src/json/encodeOutputWithPage.js @@ -1,3 +1,5 @@ +const resolveFileToURL = require('../output/helper/resolveFileToURL'); + const encodeOutput = require('./encodeOutput'); const encodePage = require('./encodePage'); const encodeFile = require('./encodeFile'); @@ -15,7 +17,7 @@ function encodeOutputWithPage(output, page) { const result = encodeOutput(output); result.page = encodePage(page, book.getSummary()); - result.file = encodeFile(file); + result.file = encodeFile(file, resolveFileToURL(output, file.getPath())); return result; } diff --git a/packages/gitbook/src/json/encodePage.js b/packages/gitbook/src/json/encodePage.js index b20a40c..0d31d7e 100644 --- a/packages/gitbook/src/json/encodePage.js +++ b/packages/gitbook/src/json/encodePage.js @@ -1,12 +1,12 @@ const encodeSummaryArticle = require('./encodeSummaryArticle'); /** - Return a JSON representation of a page - - @param {Page} page - @param {Summary} summary - @return {Object} -*/ + * Return a JSON representation of a page + * + * @param {Page} page + * @param {Summary} summary + * @return {Object} json + */ function encodePage(page, summary) { const file = page.getFile(); const attributes = page.getAttributes(); |