MCPcopy Index your code
hub / github.com/FirefoxCSS-Store/FirefoxCSS-Store.github.io / sortCards

Function sortCards

src/scripts/hub.ts:31–49  ·  view source on GitHub ↗
(visibleCards: HTMLElement[])

Source from the content-addressed store, hash-verified

29}
30
31function sortCards(visibleCards: HTMLElement[]) {
32 const sort = sortSelect?.value ?? 'latest'
33
34 return visibleCards.sort((a, b) => {
35 if (sort === 'name') {
36 return (a.dataset.title ?? '').localeCompare(b.dataset.title ?? '')
37 }
38
39 if (sort === 'popular') {
40 return Number(b.dataset.stars ?? 0) - Number(a.dataset.stars ?? 0)
41 }
42
43 if (sort === 'updated') {
44 return (b.dataset.updated ?? '').localeCompare(a.dataset.updated ?? '')
45 }
46
47 return Number(b.dataset.index ?? 0) - Number(a.dataset.index ?? 0)
48 })
49}
50
51function render() {
52 if (!grid || !count || !emptyState) return

Callers 1

renderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected