(combined, type, title, id)
| 116 | } |
| 117 | |
| 118 | function simplifyObject(combined, type, title, id): Quicklink[] { |
| 119 | return combined |
| 120 | .filter(el => (el.search && el.search[type]) || el.databaseLinks) |
| 121 | .map(el => { |
| 122 | const links: Links[] = []; |
| 123 | let quickGroup: QuicklinkGroup; |
| 124 | |
| 125 | if (el.databaseLinks) { |
| 126 | quickGroup = 'link'; |
| 127 | Object.values(el.databaseLinks).forEach((db: any) => { |
| 128 | links.push({ |
| 129 | name: db.title, |
| 130 | url: db.url, |
| 131 | }); |
| 132 | }); |
| 133 | } else if (el.search[type] === 'home') { |
| 134 | quickGroup = 'home'; |
| 135 | links.push({ |
| 136 | name: 'Homepage', |
| 137 | url: el.domain, |
| 138 | }); |
| 139 | } else { |
| 140 | quickGroup = 'search'; |
| 141 | links.push({ |
| 142 | name: 'Quicksearch', |
| 143 | url: titleSearch(el.search[type], title, id), |
| 144 | fn: searchTerm => titleSearch(el.search[type], searchTerm, id), |
| 145 | }); |
| 146 | } |
| 147 | |
| 148 | return { |
| 149 | name: el.name, |
| 150 | domain: el.domain, |
| 151 | group: quickGroup, |
| 152 | links, |
| 153 | }; |
| 154 | }); |
| 155 | } |
| 156 | |
| 157 | export async function getMalToKissApi(type, id) { |
| 158 | const url = `https://api.malsync.moe/mal/${type}/${id}`; |
no test coverage detected