Skip to content

Commit 8a7025f

Browse files
committed
feat(shared): optimize frontmatter type and support generics
1 parent e768c16 commit 8a7025f

File tree

1 file changed

+10
-10
lines changed
  • packages/@vuepress/shared/src/types

1 file changed

+10
-10
lines changed

packages/@vuepress/shared/src/types/page.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,18 @@ export type PageData<
5454
* Notice that frontmatter is parse from yaml or other languages,
5555
* so we cannot guarantee the type safety
5656
*/
57-
export interface PageFrontmatter {
58-
layout?: string | unknown
59-
permalink?: string | unknown
57+
export type PageFrontmatter<
58+
T extends Record<any, any> = Record<string, unknown>
59+
> = Partial<T> & {
60+
layout?: string
61+
permalink?: string
6062
permalinkPattern?: string
61-
date?: string | Date | unknown
63+
date?: string | Date
6264

63-
lang?: string | unknown
64-
title?: string | unknown
65-
description?: string | unknown
66-
head?: HeadConfig[] | unknown
67-
68-
[key: string]: unknown
65+
lang?: string
66+
title?: string
67+
description?: string
68+
head?: HeadConfig[]
6969
}
7070

7171
/**

0 commit comments

Comments
 (0)