Skip to content

Commit

Permalink
fix: type signature and remove JSDoc from encapsulated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
BobbieGoede committed Dec 22, 2024
1 parent 6ebb1ab commit 7558405
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 25 deletions.
6 changes: 3 additions & 3 deletions src/runtime/composables/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export function useSetI18nParams(seo?: SeoAttributesOptions): SetI18nParamsFunct
}

/**
* Returns localized head properties for locale-related tags.
* Returns localized head properties for locale-related aspects.
*
* @param options - An options object, see {@link I18nHeadOption}.
*
Expand Down Expand Up @@ -200,12 +200,12 @@ export type ResolveRouteFunction = (route: RouteLocationRaw, locale?: Locale) =>
*
* @param route - a route name or route object.
*
* @returns Route base name (without localization suffix) or `null` if no name was found.
* @returns Route base name (without localization suffix) or `undefined` if no name was found.
*/
export type RouteBaseNameFunction = <Name extends keyof RouteMapI18n = keyof RouteMapI18n>(
route: Name | RouteLocationI18nGenericPath,
locale?: Locale
) => string
) => string | undefined

/**
* Returns a {@link RouteBaseNameFunction} used get the base name of a route.
Expand Down
5 changes: 0 additions & 5 deletions src/runtime/routing/compatibles/head.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ import type { CommonComposableOptions } from '../../utils'

/**
* Returns localized head properties for locale-related aspects.
*
* @param common - Common options used internally by composable functions.
* @param options - An options, see about details {@link I18nHeadOptions}.
*
* @returns The localized {@link I18nHeadMetaInfo | head properties}.
*/
export function localeHead(
common: CommonComposableOptions,
Expand Down
22 changes: 5 additions & 17 deletions src/runtime/routing/compatibles/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,18 @@ import type { CompatRoute } from '../../types'
*
* @remarks
* Base name is name of the route without locale suffix and other metadata added by nuxt i18n module
* @param givenRoute - A route.
*
* @returns The route base name. if cannot get, `undefined` is returned.
*/
export function getRouteBaseName(common: CommonComposableOptions, givenRoute?: RouteLocation): string | undefined {
const route = unref(givenRoute)
if (route == null || !route.name) {
export function getRouteBaseName(common: CommonComposableOptions, route?: RouteLocation): string | undefined {
const _route = unref(route)
if (_route == null || !_route.name) {
return
}
const name = getRouteName(route.name)
const name = getRouteName(_route.name)
return name.split(common.runtimeConfig.public.i18n.routesNameSeparator)[0]
}

/**
* Returns localized path for passed in route.
*
* @remarks
* If locale is not specified, uses current locale.
*
* @param route - A route.
* @param locale - A locale, optional.
*
* @returns Localized equivalent of passed route
* Resolves a localized path of the passed in route.
*/
export function localePath(common: CommonComposableOptions, route: RouteLocationRaw, locale?: Locale): string {
// return external url as is
Expand Down

0 comments on commit 7558405

Please sign in to comment.