Skip to content

Commit

Permalink
better formatting of the list (part of #26)
Browse files Browse the repository at this point in the history
  • Loading branch information
fharper committed May 1, 2024
1 parent 8b4dd10 commit 139dd31
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions scripts/write-readme.js
Expand Up @@ -9,25 +9,29 @@ parentFolderPath = path.dir.split(path.sep).pop();
const data = fs.readFileSync(`${parentFolderPath}/people.json`);
const json = JSON.parse(data);

// Table header
const header = `|#|Name|URLs|Work|Topics|
|---|---|---|---|---|
`;

//Order by name
json.people.sort(function (a, b) {
return a.name.localeCompare(b.name);
});


//Generate with proper formating
const peopleList = json.people
.map(
(person) => {
(person, index) => {
let socials = [];
['Website', 'LinkedIn', 'Twitter', 'Mastodon'].forEach(social => {
if (person.hasOwnProperty(social.toLowerCase()) && person[social.toLowerCase()].length > 0) {
socials.push(`[${social}](${person[social.toLowerCase()]})`);
}
});

return `1. **[${person.name}](${person.scheduling}) (${socials.join(', ')}), ${
person.title
} at ${person.company}:** ${person.topics.join(", ")}`
return `| ${++index}. | **[${person.name}](${person.scheduling})** | ${socials.join('<br/>')} | ${person.title} at ${person.company} | ${person.topics.join(', ')} |`
}
)
.join("\r\n");
Expand All @@ -36,5 +40,5 @@ const peopleList = json.people
const template = fs.readFileSync(`${appRoot}/README-TEMPLATE.md`, "utf8");
fs.writeFileSync(
`${parentFolderPath}/README.md`,
template.replace("PLACEHOLDER", peopleList)
template.replace("PLACEHOLDER", [header, peopleList].join(""))
);

0 comments on commit 139dd31

Please sign in to comment.