]> git.ipfire.org Git - thirdparty/google/fonts.git/commitdiff
tags.html: Update url when changing commit and category 8240/head
authorMarc Foley <m.foley.88@gmail.com>
Wed, 2 Oct 2024 11:03:54 +0000 (12:03 +0100)
committerMarc Foley <m.foley.88@gmail.com>
Wed, 2 Oct 2024 13:40:27 +0000 (14:40 +0100)
.ci/tags.html

index 04f1228af4d90c9616691cadd17d435d2970c1a0..b09000a4a9a390001a505be41d47002c9ec72ba9 100644 (file)
         history: [],
       };
     },
+    watch: {
+      commit(newCommit) {
+        this.updateURL();
+      },
+      CurrentCategory(newCategory) {
+        this.updateURL();
+      }
+    },
     created() {
       this.loadCSV();
       this.loadFamilyPangrams();
     },
+    mounted() {
+      const urlParams = new URLSearchParams(window.location.search);
+      const category = urlParams.get('category');
+      if (category) {
+        this.CurrentCategory = category;
+      }
+      const commit = urlParams.get('commit');
+      if (commit) {
+        this.commit = commit;
+        this.loadCSV();
+      }
+    },
     computed: {
       sortedFamilies() {
         let ll = this.Families;
       }
     },
     methods: {
+      updateURL() {
+        const url = new URL(window.location);
+        if (this.commit) {
+          url.searchParams.set('commit', this.commit);
+        } else {
+          url.searchParams.delete('commit');
+        }
+        if (this.CurrentCategory) {
+          url.searchParams.set('category', this.CurrentCategory);
+        } else {
+          url.searchParams.delete('category');
+        }
+        history.pushState(null, '', url);
+      },
       familyPangram(family) {
         return this.Pangrams.get(this.FamilyScripts.get(family.Family));
       },