Skip to content

Commit

Permalink
Remove whole hreflang logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Matei-Iordache committed Oct 2, 2024
1 parent e4a338f commit 1dc99a6
Showing 1 changed file with 0 additions and 39 deletions.
39 changes: 0 additions & 39 deletions _src/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,6 @@ export const DEFAULT_COUNTRY = getDefaultLanguage();
export const METADATA_ANALYTICS_TAGS = 'analytics-tags';
const TARGET_TENANT = 'bitdefender';

const HREFLANG_MAP = new Map([
['en-ro', { baseUrl: 'https://www.bitdefender.ro', pageType: '.html' }],
['de', { baseUrl: 'https://www.bitdefender.de', pageType: '.html' }],
['sv', { baseUrl: 'https://www.bitdefender.se', pageType: '.html' }],
['pt', { baseUrl: 'https://www.bitdefender.pt', pageType: '.html' }],
['en-sv', { baseUrl: 'https://www.bitdefender.se', pageType: '.html' }],
['pt-BR', { baseUrl: 'https://www.bitdefender.com.br', pageType: '.html' }],
['en', { baseUrl: 'https://www.bitdefender.com', pageType: '.html' }],
['it', { baseUrl: 'https://www.bitdefender.it', pageType: '.html' }],
['fr', { baseUrl: 'https://www.bitdefender.fr', pageType: '.html' }],
['nl-BE', { baseUrl: 'https://www.bitdefender.be', pageType: '.html' }],
['es', { baseUrl: 'https://www.bitdefender.es', pageType: '.html' }],
['en-AU', { baseUrl: 'https://www.bitdefender.com.au', pageType: '' }],
['ro', { baseUrl: 'https://www.bitdefender.ro', pageType: '.html' }],
['nl', { baseUrl: 'https://www.bitdefender.nl', pageType: '.html' }],
['en-GB', { baseUrl: 'https://www.bitdefender.co.uk', pageType: '.html' }],
['zh-hk', { baseUrl: 'https://www.bitdefender.com/zh-hk', pageType: '' }],
['zh-tw', { baseUrl: 'https://www.bitdefender.com/zh-tw', pageType: '' }],
['x-default', { baseUrl: 'https://www.bitdefender.com', pageType: '.html' }],
]);

window.hlx.plugins.add('rum-conversion', {
load: 'lazy',
url: '../plugins/rum-conversion/src/index.js',
Expand Down Expand Up @@ -434,23 +413,6 @@ export default function decorateLinkedPictures(main) {
});
}

function addHreflangTags() {
if (document.querySelectorAll('head link[hreflang]').length > 0) return;

const path = window.location.pathname;
const pathCount = path.split('/').filter(String).length;
const HREFLANG_MAP_OBJECT = Object.fromEntries(HREFLANG_MAP);
Object.keys(HREFLANG_MAP_OBJECT).forEach((key) => {
const hreflang = key;
const href = `${HREFLANG_MAP_OBJECT[key].baseUrl}${path}${pathCount > 1 ? HREFLANG_MAP_OBJECT[key].pageType : ''}`;
const ln = document.createElement('link');
ln.setAttribute('rel', 'alternate');
ln.setAttribute('hreflang', hreflang);
ln.setAttribute('href', href);
document.querySelector('head').appendChild(ln);
});
}

/**
* Decorates the main element.
* @param {Element} main The main element
Expand All @@ -464,7 +426,6 @@ export function decorateMain(main) {
decorateLinkedPictures(main);
decorateSections(main);
decorateBlocks(main);
addHreflangTags();
}

/**
Expand Down

0 comments on commit 1dc99a6

Please sign in to comment.