| 288 | } |
| 289 | |
| 290 | private related() { |
| 291 | const links: any = {}; |
| 292 | const an: any[] = []; |
| 293 | if (this.animeInfo.included && this.animeInfo.included.length) { |
| 294 | this.animeInfo.included.forEach(function (i) { |
| 295 | if (i.type === 'manga' || i.type === 'anime') { |
| 296 | an[i.id] = { |
| 297 | url: `https://kitsu.app/${i.type}/${i.attributes.slug}`, |
| 298 | title: helper.getTitle(i.attributes.titles, i.attributes.canonicalTitle), |
| 299 | id: i.id, |
| 300 | type: i.type, |
| 301 | }; |
| 302 | } |
| 303 | }); |
| 304 | |
| 305 | this.animeInfo.included.forEach(function (i) { |
| 306 | if (i.type === 'mediaRelationships') { |
| 307 | if (typeof links[i.attributes.role] === 'undefined') { |
| 308 | let title = i.attributes.role.toLowerCase().replace('_', ' '); |
| 309 | title = title.charAt(0).toUpperCase() + title.slice(1); |
| 310 | |
| 311 | links[i.attributes.role] = { |
| 312 | type: title, |
| 313 | links: [], |
| 314 | }; |
| 315 | } |
| 316 | const tempEl = an[i.relationships.destination.data.id]; |
| 317 | links[i.attributes.role].links.push(tempEl); |
| 318 | } |
| 319 | }); |
| 320 | } |
| 321 | this.meta.related = Object.keys(links).map(key => links[key]); |
| 322 | } |
| 323 | |
| 324 | protected apiCall = helper.apiCall; |
| 325 | } |