From: Marc Foley Date: Wed, 28 May 2025 15:21:52 +0000 (+0100) Subject: fix trending and popularity sort X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=refs%2Fpull%2F9515%2Fhead;p=thirdparty%2Fgoogle%2Ffonts.git fix trending and popularity sort --- diff --git a/.ci/tags.html b/.ci/tags.html index c48fac97f..f94dc9384 100644 --- a/.ci/tags.html +++ b/.ci/tags.html @@ -293,7 +293,7 @@ function axesCombos(axes) { return this.family.toStyle(); }, familyDisplayName() { - return this.family.displayName; + return `${this.family.displayName}`; }, familyTag() { return this.family.tag @@ -381,12 +381,27 @@ function axesCombos(axes) { sortFunc = function(a, b) {return a.displayName.localeCompare(b.displayName)} } else if (["Popularity", "Trending"].includes(this.sortMethod)) { sortFunc = function(a, b) { - const aFamilyData = _this.familyData[b.displayName] - const bFamilyData = _this.familyData[a.displayName] - if (aFamilyData === undefined || bFamilyData === undefined) { + let aVal, bVal; + const aFamilyData = _this.familyData[a.displayName] + const bFamilyData = _this.familyData[b.displayName] + if (aFamilyData === undefined) { + aVal = Number.MAX_SAFE_INTEGER; + } else { + aVal = aFamilyData[_this.sortMethod.toLowerCase()]; + } + if (bFamilyData === undefined) { + bVal = Number.MAX_SAFE_INTEGER; + } else { + bVal = bFamilyData[_this.sortMethod.toLowerCase()]; + } + + if (aVal < bVal) { + return -1; + } else if (aVal > bVal) { return 1; + } else { + return 0; } - return bFamilyData[_this.sortMethod.toLowerCase()] - aFamilyData[_this.sortMethod.toLowerCase()]; } } let filtered = this.tags; @@ -398,6 +413,7 @@ function axesCombos(axes) { } filtered.sort(sortFunc); + if (this.reverseTags) { filtered.reverse(); }