_build.js
/**
 * Generates a service (such as Gmail) section to be placed under a category section
 * @param {Array} data
 */
Generates a service (such as Gmail) section to be placed under a category section
@param {Array} data
Generates a service ( such as Gmail ) section to be placed under a category section @param { Array } data
function generateServiceSection(data) {
    let serviceSection = `#### ${data[0].title + os.EOL + os.EOL}`;
    let notes = os.EOL + '';
    let tableHeader = `| Name | Eyes | Description |${os.EOL}| ---- | ---- | ----------- |${os.EOL}`;
    if (data.filter((d) => 'name' in d).length === 0) tableHeader = `No known alternatives.${os.EOL}`;
    serviceSection = serviceSection.concat(tableHeader);
    data.forEach((item) => {
        if (Object.keys(item).length == 1) {
            if (!item.notes) return;
            else item.notes.forEach((note) => notes = notes.concat(`- *${note.trim()}*${os.EOL}`));
        } else {
            let name = `[${item.name}](${item.url})`;
            let eyes = item.eyes ? `**${item.eyes}-eyes**` : '';
            let text = item.text.trim();
            if (item.fdroid) name = name.concat('<br/>', fdroidLink(item.fdroid));
            if (item.repo) name = name.concat('<br/>', repoLink(item.repo));
            let tableItem = `| ${name} | ${eyes} | ${text} |${os.EOL}`;
            serviceSection = serviceSection.concat(tableItem);
        }
    });
    return `${serviceSection}${notes}`;
}
function generateServiceSection ( data ) { let serviceSection = ` ${ data [ 0 ] . title + os . EOL + os . EOL } ` ; let notes = os . EOL + '' ; let tableHeader = ` ${ os . EOL } ${ os . EOL } ` ; if ( data . filter ( ( d ) => 'name' in d ) . length === 0 ) tableHeader = ` ${ os . EOL } ` ; serviceSection = serviceSection . concat ( tableHeader ) ; data . forEach ( ( item ) => { if ( Object . keys ( item ) . length == 1 ) { if ( ! item . notes ) return ; else item . notes . forEach ( ( note ) => notes = notes . concat ( ` ${ note . trim ( ) } ${ os . EOL } ` ) ) ; } else { let name = ` ${ item . name } ${ item . url } ` ; let eyes = item . eyes ? ` ${ item . eyes } ` : '' ; let text = item . text . trim ( ) ; if ( item . fdroid ) name = name . concat ( '<br/>' , fdroidLink ( item . fdroid ) ) ; if ( item . repo ) name = name . concat ( '<br/>' , repoLink ( item . repo ) ) ; let tableItem = ` ${ name } ${ eyes } ${ text } ${ os . EOL } ` ; serviceSection = serviceSection . concat ( tableItem ) ; } } ) ; return ` ${ serviceSection } ${ notes } ` ; }
Generates a service (such as Gmail) section to be placed under a category section
 @param {Array} data
Generates a service ( such as Gmail ) section to be placed under a category section @param { Array } data
// Start the section with an <h4> header // Prep section notes // If there is data to be displayed, add the start of a Markdown table // Add the header to the section body // Iterate over each alternative service and add it to the table // If the object has length one, it's either title or note // Build the cells for the table // Append the F-Droid badge to the name // Append the Repo badge to the name // Build the row // Add the row to the table