Add typecheck
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { RouteParamsGeneric } from '#vue-router';
|
||||
import type { RouteParamsGeneric } from 'vue-router';
|
||||
|
||||
export type Slug = { name: string; id: number };
|
||||
export type SlugRecord = Record<string, Slug>;
|
||||
@@ -16,12 +16,13 @@ export function parseSlug(slug: string): null | Slug {
|
||||
const { name, id } = result.groups!;
|
||||
|
||||
return {
|
||||
name: name
|
||||
.substring(0, name.length - 1)
|
||||
.split('-')
|
||||
.map((w) => `${w.substring(0, 1).toUpperCase()}${w.substring(1)}`)
|
||||
.join(' '),
|
||||
id: parseInt(id)
|
||||
name:
|
||||
name
|
||||
?.substring(0, name.length - 1)
|
||||
.split('-')
|
||||
.map((w) => `${w.substring(0, 1).toUpperCase()}${w.substring(1)}`)
|
||||
.join(' ') ?? '',
|
||||
id: parseInt(id!)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user