Skip to content

Commit

Permalink
Merge pull request #8240 from google/tag-url
Browse files Browse the repository at this point in the history
tags.html: Update url when changing commit and category
  • Loading branch information
m4rc1e authored Oct 2, 2024
2 parents 2daa651 + f62d521 commit 8f4fe8e
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .ci/tags.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,30 @@ <h1>Google Fonts Tagger</h1>
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;
Expand All @@ -129,6 +149,20 @@ <h1>Google Fonts Tagger</h1>
}
},
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));
},
Expand Down

0 comments on commit 8f4fe8e

Please sign in to comment.