@@ -12,11 +12,14 @@ const Wiki = sites => {
12 const storeEntry = (author, url, category, term, entry) => {
12 const storeEntry = (author, url, category, term, entry) => {
13 if (!(category in entries)) {
13 if (!(category in entries)) {
14 entries[category] = {}
14 entries[category] = {}
15− entries[category][term] = [{ entry, author, url }]
15+ entries[category][term] = [{ entry, authors: [{ author, url }] }]
16 } else if (!(term in entries[category])) {
16 } else if (!(term in entries[category])) {
17− entries[category][term] = [{ entry, author, url }]
17+ entries[category][term] = [{ entry, authors: [{ author, url }] }]
19+ const possibleIndex = entries[category][term].findIndex(existing => existing.entry === entry)
21+ ? entries[category][term][possibleIndex].authors.push({ author, url })
19− entries[category][term].push({ entry, author, url })
22+ : entries[category][term].push({ entry, authors: [{ author, url }] })
21 terms.add(term)
24 terms.add(term)
22 authors.add(author)
25 authors.add(author)
@@ -60,15 +63,19 @@ const Wiki = sites => {
60 '<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>'
63 '<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>'
66+ const formatAuthor = (authors, author) => {
67+ return `${authors}<a class='author' target='_blank' href='${author.url}'> @${author.author}</a>`
63 const formatEntry = (definitions, definition) => {
70 const formatEntry = (definitions, definition) => {
64 const formatEntryList = entryList => entryList.reduce((items, item) => `${items}<li>${formatLinks(item)}</li>`, '')
71 const formatEntryList = entryList => entryList.reduce((items, item) => `${items}<li>${formatLinks(item)}</li>`, '')
66 const newHtml = typeof definition.entry === 'string'
73 const newHtml = typeof definition.entry === 'string'
67 ? `<li>${formatLinks(definition.entry)}
74 ? `<li>${formatLinks(definition.entry)}
68− - <a class='author' target='_blank' href='${definition.url}'> @${definition.author}</a>
75+ - ${definition.authors.reduce(formatAuthor, '')}
70 : `<li><ul>${formatEntryList(definition.entry)}
77 : `<li><ul>${formatEntryList(definition.entry)}
71− <a class='author' target='_blank' href='${definition.url}'> — @${definition.author}</a>
78+ - ${definition.authors.reduce(formatAuthor, '')}
72 </ul></li>`
79 </ul></li>`
74 return `${definitions}${newHtml}`
81 return `${definitions}${newHtml}`