From d27b9885b7e0cf9e0eecc1de9d7e47eb72363873 Mon Sep 17 00:00:00 2001 From: Stephen Brown II Date: Tue, 1 Sep 2020 12:53:35 -0600 Subject: [PATCH 1/2] Only add Markdown table headers if there is data to be displayed --- _build.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/_build.js b/_build.js index 17ceec0..1fa86a5 100644 --- a/_build.js +++ b/_build.js @@ -100,9 +100,12 @@ function generateCategorySection(header, data) { * @param {Array} data */ function generateServiceSection(data) { - // Start the section with an

header and the start of a Markdown table - let serviceSection = `#### ${data[0].title + os.EOL + os.EOL}| Name | Eyes | Description |${os.EOL}| ---- | ---- | ----------- |${os.EOL}`; + // Start the section with an

header + let serviceSection = `#### ${data[0].title + os.EOL + os.EOL}`; let notes = os.EOL + ''; + // If there is data to be displayed, add the start of a Markdown table + let tableHeader = `| Name | Eyes | Description |${os.EOL}| ---- | ---- | ----------- |${os.EOL}`; + if (data.filter(d => "name" in d).length > 0) serviceSection = serviceSection.concat(tableHeader); // Iterate over each alternative service and add it to the table data.forEach(item => { // If the object has length one, it's either title or note From b6d883b11de98a0aa481eb50c56809ffcf3a4cac Mon Sep 17 00:00:00 2001 From: Stephen Brown II Date: Tue, 1 Sep 2020 13:11:37 -0600 Subject: [PATCH 2/2] Use "No known alternatives." instead of empty section. --- _build.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_build.js b/_build.js index 1fa86a5..ca25ec1 100644 --- a/_build.js +++ b/_build.js @@ -105,7 +105,8 @@ function generateServiceSection(data) { let notes = os.EOL + ''; // If there is data to be displayed, add the start of a Markdown table let tableHeader = `| Name | Eyes | Description |${os.EOL}| ---- | ---- | ----------- |${os.EOL}`; - if (data.filter(d => "name" in d).length > 0) serviceSection = serviceSection.concat(tableHeader); + if (data.filter(d => 'name' in d).length == 0) tableHeader = `No known alternatives.${os.EOL}`; + serviceSection = serviceSection.concat(tableHeader); // Iterate over each alternative service and add it to the table data.forEach(item => { // If the object has length one, it's either title or note