function Links()

in support-frontend/assets/components/headers/links/links.tsx [100:179]


function Links({ location, getRef, countryGroupId }: PropTypes): JSX.Element {
	const { protocol, host, pathname } = window.location;
	const urlWithoutParams = `${protocol}//${host}${pathname}`;
	const internationalisationIDValue = internationalisationID(countryGroupId);
	const isNotUk = internationalisationIDValue !== 'uk';
	return (
		<nav
			className={classNameWithModifiers('component-header-links', [location])}
		>
			<ul className="component-header-links__ul" ref={getRef}>
				{links
					.filter(({ text }) => {
						if (
							text === 'Digital' ||
							text === 'Support' ||
							text === 'Contributions' ||
							(text === 'Newspaper' && isNotUk) ||
							(text === 'Subscriptions' && isNotUk)
						) {
							return false;
						}
						return true;
					})
					.filter(({ include, exclude }) => {
						// If there is no country group ID for the link, return true and include the link in the rendering.
						if (!countryGroupId) {
							return true;
						}

						// If the link is not meant to be included for a specific CountryGroupID, do not include in array.
						if (include && !include.includes(countryGroupId)) {
							return false;
						}

						// If the link is meant to be excluded for a specific CountryGroupID, exclude from array.
						if (exclude?.includes(countryGroupId)) {
							return false;
						}

						// Otherwise return true.
						return true;
					})
					.map((link) => {
						if (internationalisationIDValue == null || !link.internal) {
							return link;
						}

						return {
							...link,
							href: `/${internationalisationIDValue}${link.href}`,
						};
					})
					.map(
						({ href, text, trackAs, opensInNewWindow, additionalClasses }) => (
							<li
								className={cx(
									classNameWithModifiers('component-header-links__li', [
										getActiveLinkClassModifiers(urlWithoutParams, href),
									]),
									additionalClasses,
								)}
							>
								<a
									onClick={sendTrackingEventsOnClick({
										id: ['header-link', trackAs, location].join(' - '),
										componentType: 'ACQUISITIONS_OTHER',
									})}
									className="component-header-links__link"
									href={href}
									target={opensInNewWindow ? '_blank' : ''}
								>
									{text}
								</a>
							</li>
						),
					)}
			</ul>
		</nav>
	);
}