1
0
mirror of https://github.com/tycrek/degoogle.git synced 2025-08-10 00:46:31 +02:00

Added note parsing ability to _build.js

This commit is contained in:
tycrek
2020-05-25 08:00:51 -06:00
parent 9066dbc24f
commit 09a6b0c520

View File

@@ -99,25 +99,28 @@ function generateCategorySection(header, data) {
function generateServiceSection(data) { function generateServiceSection(data) {
// Start the section with an <h4> header and the start of a Markdown table // Start the section with an <h4> header and the start of a Markdown table
let serviceSection = `#### ${data[0].title + os.EOL + os.EOL}| Name | Eyes | Description |${os.EOL}| ---- | ---- | ----------- |${os.EOL}`; let serviceSection = `#### ${data[0].title + os.EOL + os.EOL}| Name | Eyes | Description |${os.EOL}| ---- | ---- | ----------- |${os.EOL}`;
let notes = os.EOL + '';
// Iterate over each alternative service and add it to the table // Iterate over each alternative service and add it to the table
data.forEach(item => { data.forEach(item => {
// If the object has length one, it's just the title // If the object has length one, it's either title or note
if (Object.keys(item).length == 1) return; if (Object.keys(item).length == 1) {
if (!item.notes) return;
// Build the cells for the table else item.notes.forEach((note) => notes = notes.concat(`- *${note.trim()}*${os.EOL}`))
let name = `[${item.name}](${item.url})`; } else {
let eyes = item.eyes ? `**${item.eyes}-eyes**` : ''; // Build the cells for the table
let text = item.text.trim(); let name = `[${item.name}](${item.url})`;
let eyes = item.eyes ? `**${item.eyes}-eyes**` : '';
// Build the row let text = item.text.trim();
let tableItem = `| ${name} | ${eyes} | ${text} |`;
// Build the row
// Add the row to the table let tableItem = `| ${name} | ${eyes} | ${text} |`;
serviceSection = serviceSection.concat(tableItem + os.EOL)
// Add the row to the table
serviceSection = serviceSection.concat(tableItem + os.EOL)
}
}); });
return serviceSection; return serviceSection + notes;
} }
__main__(); __main__();