mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Add benchmark and performance links to search
This commit is contained in:
parent
f1a772b905
commit
f62f33d98c
4 changed files with 138 additions and 33 deletions
|
|
@ -3,6 +3,9 @@ import gameList from '~/static/game-list.json'
|
|||
import homebrewList from '~/static/homebrew-list.json'
|
||||
|
||||
import { byTimeThenNull } from '~/helpers/sort-list.js'
|
||||
import { videosRelatedToApp } from '~/helpers/related.js'
|
||||
import { getAppEndpoint } from '~/helpers/app-derived.js'
|
||||
|
||||
|
||||
export const allVideoAppsList = [
|
||||
...appList.sort(byTimeThenNull),
|
||||
|
|
@ -16,3 +19,54 @@ export const allList = [
|
|||
...homebrewList,
|
||||
...gameList,
|
||||
]
|
||||
|
||||
|
||||
export function makeAppSearchLinks (app) {
|
||||
|
||||
const videos = videosRelatedToApp(app)
|
||||
|
||||
// If there are no videos
|
||||
// then skip
|
||||
if (videos.length === 0) return []
|
||||
|
||||
const searchLinks = []
|
||||
|
||||
const appBenchmarksUrl = `${getAppEndpoint(app)}/benchmarks`
|
||||
|
||||
let hasPerformanceVideo = false
|
||||
|
||||
for (const video of videos) {
|
||||
// If there are no video tags
|
||||
// then skip
|
||||
if (video.tags.length === 0) continue
|
||||
|
||||
// If there's any benchmark video then add
|
||||
if (video.tags.includes('benchmark')) {
|
||||
// Add a benchmark link
|
||||
searchLinks.push({
|
||||
href: appBenchmarksUrl,
|
||||
label: 'Benchmarks'
|
||||
})
|
||||
|
||||
// then stop looking
|
||||
break
|
||||
}
|
||||
|
||||
if (video.tags.includes('performance')) {
|
||||
hasPerformanceVideo = true
|
||||
}
|
||||
}
|
||||
|
||||
// If there was no bechmark video found
|
||||
// but there was a performance video found
|
||||
// then push Performance link
|
||||
if (searchLinks.length === 0 && hasPerformanceVideo) {
|
||||
// Add a performance link
|
||||
searchLinks.push({
|
||||
href: appBenchmarksUrl,
|
||||
label: 'Performance'
|
||||
})
|
||||
}
|
||||
|
||||
return searchLinks
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue