<commit_before>// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

import HeaderLink from 'interfaces/header-link';
import UserJsonExtended from 'interfaces/user-json-extended';
import { route } from 'laroute';

export default function headerLinks(user: UserJsonExtended, active: 'modding' | 'multiplayer' | 'show') {
  const links: HeaderLink[] = [{
    active: active === 'show',
    title: osu.trans('layout.header.users.show'),
    url: route('users.show', { user: user.id }),
  }];

  if (!user.is_bot) {
    links.push({
      active: active === 'modding',
      title: osu.trans('layout.header.users.modding'),
      url: route('users.modding.index', { user: user.id }),
    });

    links.push({
      active: active === 'multiplayer',
      title: osu.trans('layout.header.users.multiplayer'),
      url: route('users.multiplayer.index', { user: user.id }),
    });
  }

  return links;
}<commit_msg>just loop instead<commit_after>// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

import HeaderLink from 'interfaces/header-link';
import UserJsonExtended from 'interfaces/user-json-extended';
import { route } from 'laroute';

type LinkMode = 'modding' | 'multiplayer' | 'show';

const nonBotModes: LinkMode[] = ['modding', 'multiplayer'];

export default function headerLinks(user: UserJsonExtended, active: LinkMode) {
  const links: HeaderLink[] = [{
    active: active === 'show',
    title: osu.trans('layout.header.users.show'),
    url: route('users.show', { user: user.id }),
  }];

  if (!user.is_bot) {
    nonBotModes.forEach((mode) => {
      links.push({
        active: active === mode,
        title: osu.trans(`layout.header.users.${mode}`),
        url: route(`users.${mode}.index`, { user: user.id }),
      });
    });
  }

  return links;
}
{'fraction_non_alphanumeric': 0.16051844466600199, 'fraction_numerical': 0.0019940179461615153, 'mean_word_length': 3.6351039260969977, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5994154', 'n_tokens_mistral': 635, 'n_tokens_neox': 626, 'n_words': 171}