<commit_before>// Imports
import languages from '@/i18n/locales'
import { kebabCase } from 'lodash'
import { leadingSlash, trailingSlash } from '@/util/helpers'

// Globals
import { IN_BROWSER } from '@/util/globals'

// Regexp
const genericLocaleRegexp = /[a-z]{2,3}|[a-z]{2,3}-[a-zA-Z]{4}|[a-z]{2,3}-[A-Z]{2,3}/
const fallbackLocale = genericLocaleRegexp.source
const languagePattern = languages.map(lang => lang.alternate || lang.locale).join('|')

export function layout (layout = 'Default', children, path = '') {
  const dir = kebabCase(layout)

  return {
    children,
    component: () => import(
      /* webpackChunkName: "layout-[request]" */
      `@/layouts/${dir}/Index`
    ),
    path,
  }
}

export function locale (children = []) {
  return layout(
    'Locale',
    children,
    `/:locale(${languagePattern})`,
  )
}

export function preferredLocale (locale = 'en') {
  const languageRegexp = new RegExp('^(' + languagePattern + ')$')

  if (!IN_BROWSER) return locale

  return (
    window.localStorage.getItem('currentLanguage') ||
    navigator.languages.find(l => l.match(languageRegexp)) ||
    locale
  )
}

export function redirect (
  path = '*',
  rhandler,
  fallback = fallbackLocale,
) {
  if (typeof path === 'function') {
    rhandler = path
    path = '*'
  }

  path = path.replace('%s', fallback)

  return {
    path,
    redirect: to => {
      const locale = preferredLocale()
      const rpath = rhandler(to)
      const url = rpath !== ''
        ? leadingSlash(trailingSlash(rpath))
        : rpath

      return `/${locale}${url}`
    },
  }
}

export function route (name, component, path = '') {
  component = Object(component) === component
    ? component
    : { default: name }

  const components = {}

  for (const key in component) {
    components[key] = () => import(
      /* webpackChunkName: "views-[request]" */
      `@/views/${name}`
    )
  }

  return {
    name,
    components,
    path,
  }
}<commit_msg>fix(routes): api pages were using documentation view<commit_after>// Imports
import languages from '@/i18n/locales'
import { kebabCase } from 'lodash'
import { leadingSlash, trailingSlash } from '@/util/helpers'

// Globals
import { IN_BROWSER } from '@/util/globals'

// Regexp
const genericLocaleRegexp = /[a-z]{2,3}|[a-z]{2,3}-[a-zA-Z]{4}|[a-z]{2,3}-[A-Z]{2,3}/
const fallbackLocale = genericLocaleRegexp.source
const languagePattern = languages.map(lang => lang.alternate || lang.locale).join('|')

export function layout (layout = 'Default', children, path = '') {
  const dir = kebabCase(layout)

  return {
    children,
    component: () => import(
      /* webpackChunkName: "layout-[request]" */
      `@/layouts/${dir}/Index`
    ),
    path,
  }
}

export function locale (children = []) {
  return layout(
    'Locale',
    children,
    `/:locale(${languagePattern})`,
  )
}

export function preferredLocale (locale = 'en') {
  const languageRegexp = new RegExp('^(' + languagePattern + ')$')

  if (!IN_BROWSER) return locale

  return (
    window.localStorage.getItem('currentLanguage') ||
    navigator.languages.find(l => l.match(languageRegexp)) ||
    locale
  )
}

export function redirect (
  path = '*',
  rhandler,
  fallback = fallbackLocale,
) {
  if (typeof path === 'function') {
    rhandler = path
    path = '*'
  }

  path = path.replace('%s', fallback)

  return {
    path,
    redirect: to => {
      const locale = preferredLocale()
      const rpath = rhandler(to)
      const url = rpath !== ''
        ? leadingSlash(trailingSlash(rpath))
        : rpath

      return `/${locale}${url}`
    },
  }
}

export function route (name, component, path = '') {
  component = Object(component) === component
    ? component
    : { default: name }

  const components = {}

  for (const [key, value] of Object.entries(component)) {
    components[key] = () => import(
      /* webpackChunkName: "views-[request]" */
      `@/views/${value}`
    )
  }

  return {
    name,
    components,
    path,
  }
}
{'fraction_non_alphanumeric': 0.16687453230231977, 'fraction_numerical': 0.0054876527812422055, 'mean_word_length': 3.0546006066734073, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '4900692', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1331, 'n_words': 287}