build(aio): add the `id` to the DocumentContents at doc-gen time (#16139)

This commit is contained in:
Peter Bacon Darwin 2017-04-20 12:55:34 +01:00 committed by Miško Hevery
parent 6ed812ff75
commit d0dcabd700
2 changed files with 3 additions and 1 deletions

View File

@ -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);
}
});
}

View File

@ -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');
});