From b4b8855ef57fef14510e164a12b3731f10afeb56 Mon Sep 17 00:00:00 2001 From: Lars Trieloff Date: Tue, 14 Jan 2020 11:51:30 +0100 Subject: [PATCH] fix(markdown): catch error when using `title` as a property name --- lib/markdownBuilder.js | 2 +- test/markdownBuilder.test.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/markdownBuilder.js b/lib/markdownBuilder.js index 1c51bfac..b4839ba8 100644 --- a/lib/markdownBuilder.js +++ b/lib/markdownBuilder.js @@ -414,7 +414,7 @@ function build({ })(); const typelink = (() => { - if (definition[keyword`title`]) { + if (definition[keyword`title`] && typeof definition[keyword`title`] === 'string') { // if the type has a title, always create a link to the schema return [text(' ('), link(`${definition[s.slug]}.md`, '', text(definition[keyword`title`])), text(')')]; } else if (!singletype || firsttype === keyword`object` || merged) { diff --git a/test/markdownBuilder.test.js b/test/markdownBuilder.test.js index c1a02685..dbc36101 100644 --- a/test/markdownBuilder.test.js +++ b/test/markdownBuilder.test.js @@ -75,6 +75,11 @@ describe('Testing Markdown Builder: title', () => { assertMarkdown(results.meta) .fuzzy`defined in: [Meta](meta-definitions-meta-properties-title.md "https://ns.adobe.com/helix/pipeline/meta#/definitions/meta/properties/title")`; }); + + it('Title Schema looks OK', () => { + assertMarkdown(results['meta-definitions-meta-properties']) + .fuzzy`properties Type`; + }); }); describe('Testing Markdown Builder: enums', () => {