Skip to content

Commit

Permalink
Merge pull request #174 from moiz-deriv/moiz/migration-href-lang
Browse files Browse the repository at this point in the history
refactor: migration of code responsible for href lang removal for specific pages
  • Loading branch information
moiz-deriv authored Oct 15, 2024
2 parents c88c4ad + 805a737 commit 507eac9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/js/footer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ import "./disclaimerAddClassname";
import "./mobileMenuAccordian";
import "./partnerAffiliate";
import "./loginFunctions";
import "./removeHrefLang";
25 changes: 25 additions & 0 deletions src/js/footer/removeHrefLang/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
document.addEventListener("DOMContentLoaded", () => {
var targetPaths = [
"/careers",
"/locations",
"/derivtech",
"/derivlife",
"/eu-careers",
"/our-locations",
"/product-explorer",
"/academy",
"/trading-terms-glossary",
];
var path = window.location.pathname;
if (targetPaths.some((targetPath) => path.includes(targetPath))) {
var headTag = document.head;
var linkElements = headTag.querySelectorAll("link");
linkElements.forEach(function (linkElement) {
if (linkElement.hasAttribute("hreflang")) {
if (linkElement.getAttribute("hreflang") !== "x-default") {
linkElement.remove();
}
}
});
}
});

0 comments on commit 507eac9

Please sign in to comment.