]> git.ipfire.org Git - thirdparty/google/fonts.git/commitdiff
fix trending and popularity sort 9515/head
authorMarc Foley <m.foley.88@gmail.com>
Wed, 28 May 2025 15:21:52 +0000 (16:21 +0100)
committerMarc Foley <m.foley.88@gmail.com>
Wed, 28 May 2025 15:21:52 +0000 (16:21 +0100)
.ci/tags.html

index c48fac97f8945c5cc850a9948185ef454e2f9e9b..f94dc938452af31eeae4855c08039809bab631cc 100644 (file)
@@ -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();
         }