@@ -12,11 +12,14 @@ const Wiki = sites => {
1212 const storeEntry = (author, url, category, term, entry) => {
1313 if (!(category in entries)) {
1414 entries[category] = {}
15− entries[category][term] = [{ entry, author, url }]
15+ entries[category][term] = [{ entry, authors: [{ author, url }] }]
1616 } else if (!(term in entries[category])) {
17− entries[category][term] = [{ entry, author, url }]
17+ entries[category][term] = [{ entry, authors: [{ author, url }] }]
1818 } else {
19− entries[category][term].push({ entry, author, url })
19+ const possibleIndex = entries[category][term].findIndex(existing => existing.entry === entry)
20+ possibleIndex > -1
21+ ? entries[category][term][possibleIndex].authors.push({ author, url })
22+ : entries[category][term].push({ entry, authors: [{ author, url }] })
2023 }
2124 terms.add(term)
2225 authors.add(author)
@@ -60,15 +63,19 @@ const Wiki = sites => {
6063 '<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>'
6164 )
6265
66+ const formatAuthor = (authors, author) => {
67+ return `${authors}<a class='author' target='_blank' href='${author.url}'> @${author.author}</a>`
68+ }
69+
6370 const formatEntry = (definitions, definition) => {
6471 const formatEntryList = entryList => entryList.reduce((items, item) => `${items}<li>${formatLinks(item)}</li>`, '')
6572
6673 const newHtml = typeof definition.entry === 'string'
6774 ? `<li>${formatLinks(definition.entry)}
68− - <a class='author' target='_blank' href='${definition.url}'> @${definition.author}</a>
75+ - ${definition.authors.reduce(formatAuthor, '')}
6976 </li>`
7077 : `<li><ul>${formatEntryList(definition.entry)}
71− <a class='author' target='_blank' href='${definition.url}'> — @${definition.author}</a>
78+ - ${definition.authors.reduce(formatAuthor, '')}
7279 </ul></li>`
7380
7481 return `${definitions}${newHtml}`