Skip to content

Commit 5e3acd5

Browse files
committed
docs: add api docs
1 parent ec5b366 commit 5e3acd5

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed

src/h3.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ export function setCookieLocale(
226226
*
227227
* @param {H3Event} event the {@link H3Event | H3} event
228228
* @param {PathOptions['lang']} options.lang the language tag, which is as default `'en-US'`. optional
229-
* @param {PathOptions['parser']} options.parser the path language parser, optional
229+
* @param {PathOptions['parser']} options.parser the path language parser, default {@link pathLanguageParser}, optional
230230
*
231231
* @throws {RangeError} Throws the {@link RangeError} if the language in the path, that is not a well-formed BCP 47 language tag.
232232
*

src/hono.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ export function setCookieLocale(
234234
*
235235
* @param {Context} context A {@link Context | Hono} context
236236
* @param {PathOptions['lang']} options.lang A language tag, which is as default `'en-US'`. optional
237-
* @param {PathOptions['parser']} options.parser A path language parser, optional
237+
* @param {PathOptions['parser']} options.parser the path language parser, default {@link pathLanguageParser}, optional
238238
*
239239
* @throws {RangeError} Throws the {@link RangeError} if the language in the path, that is not a well-formed BCP 47 language tag.
240240
*

src/node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ function getURL(request: IncomingMessage): URL {
289289
*
290290
* @param {IncomingMessage} request the {@link IncomingMessage | request}
291291
* @param {PathOptions['lang']} options.lang the language tag, which is as default `'en-US'`. optional
292-
* @param {PathOptions['parser']} options.parser the path language parser, optional
292+
* @param {PathOptions['parser']} options.parser the path language parser, default {@link pathLanguageParser}, optional
293293
*
294294
* @throws {RangeError} Throws the {@link RangeError} if the language in the path, that is not a well-formed BCP 47 language tag.
295295
*

src/shared.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ export interface PathLanguageParser {
9898
(path: string | URL): string
9999
}
100100

101+
/**
102+
* create a parser, which can split with slash `/`
103+
*
104+
* @param index An index of locale, which is included in path
105+
*
106+
* @returns A return a parser, which has {@link PathLanguageParser} interface
107+
*/
101108
export function createPathIndexLanguageParser(
102109
index = 0,
103110
): PathLanguageParser {
@@ -112,6 +119,12 @@ export function createPathIndexLanguageParser(
112119
}
113120
}
114121

122+
/**
123+
* A path parser that can get the zeroth part of a path split by `/` as local value
124+
*
125+
* @description
126+
* - `/en/nest/about` -> `en`
127+
*/
115128
export let pathLanguageParser: PathLanguageParser = /* #__PURE__*/ createPathIndexLanguageParser()
116129

117130
/**

src/web.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ export function setCookieLocale(
251251
*
252252
* @param {Request} request the {@link Request | request}
253253
* @param {PathOptions['lang']} options.lang the language tag, which is as default `'en-US'`. optional
254-
* @param {PathOptions['parser']} options.parser the path language parser, optional
254+
* @param {PathOptions['parser']} options.parser the path language parser, default {@link pathLanguageParser}, optional
255255
*
256256
* @throws {RangeError} Throws the {@link RangeError} if the language in the path, that is not a well-formed BCP 47 language tag.
257257
*

0 commit comments

Comments
 (0)