Skip to content

Commit

Permalink
πŸ”οΈ Add q & tag in store canonical URL (#1920)
Browse files Browse the repository at this point in the history
* πŸ”οΈ Add q in store canonical url

* πŸ› Fix i18n canonical url was not overwritten
  • Loading branch information
williamchong authored Oct 29, 2024
1 parent 3270c61 commit 79d2acc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/pages/store/articles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ export default {
body: true,
},
],
link: [{ rel: 'canonical', href: `${this.$route.path}` }],
};
},
computed: {
Expand Down
19 changes: 18 additions & 1 deletion src/pages/store/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,13 @@ export default {
head() {
const title = this.$t('store_index_page_title');
const description = this.$t('store_books_page_description');
const link = [{ rel: 'canonical', href: `${this.$route.path}` }];
const link = [
{
hid: 'i18n-can',
rel: 'canonical',
href: this.canonicalLink,
},
];
const classIds = Array.from(
new Set(this.bookstoreItems.map(b => b.classId).flat())
);
Expand Down Expand Up @@ -604,6 +610,17 @@ export default {
'getNFTClassMetadataById',
]),
canonicalLink() {
const baseUrl = `${EXTERNAL_HOST}${this.$route.path}`;
const { tag, q } = this.$route.query;
if (tag) {
return `${baseUrl}?tag=${tag}`;
}
if (q && this.sortedBookstoreItems.length) {
return `${baseUrl}?q=${q}`;
}
return baseUrl;
},
// Price filter related
priceFilterList() {
return [
Expand Down

0 comments on commit 79d2acc

Please sign in to comment.