From d0dcabd700954ad95abe61c56f243ee2988d875c Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Thu, 20 Apr 2017 12:55:34 +0100 Subject: [PATCH] build(aio): add the `id` to the DocumentContents at doc-gen time (#16139) --- .../transforms/angular.io-package/processors/convertToJson.js | 2 +- .../angular.io-package/processors/convertToJson.spec.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/aio/tools/transforms/angular.io-package/processors/convertToJson.js b/aio/tools/transforms/angular.io-package/processors/convertToJson.js index 230f524a3c..1506306065 100644 --- a/aio/tools/transforms/angular.io-package/processors/convertToJson.js +++ b/aio/tools/transforms/angular.io-package/processors/convertToJson.js @@ -31,7 +31,7 @@ module.exports = function convertToJsonProcessor(log, createDocMessage) { log.warn(createDocMessage('Title property expected', doc)); } - doc.renderedContent = JSON.stringify({ title, contents }, null, 2); + doc.renderedContent = JSON.stringify({ id: doc.path, title, contents }, null, 2); } }); } diff --git a/aio/tools/transforms/angular.io-package/processors/convertToJson.spec.js b/aio/tools/transforms/angular.io-package/processors/convertToJson.spec.js index 17a073b004..8f336b983c 100644 --- a/aio/tools/transforms/angular.io-package/processors/convertToJson.spec.js +++ b/aio/tools/transforms/angular.io-package/processors/convertToJson.spec.js @@ -21,9 +21,11 @@ describe('convertToJson processor', () => { docType: 'test-doc', title: 'The Title', name: 'The Name', + path: 'test/doc', renderedContent: 'Some Content' }]; processor.$process(docs); + expect(JSON.parse(docs[0].renderedContent).id).toEqual('test/doc'); expect(JSON.parse(docs[0].renderedContent).title).toEqual('The Title'); expect(JSON.parse(docs[0].renderedContent).contents).toEqual('Some Content'); });