Skip to content

Commit

Permalink
feat: support repeatable links in models
Browse files Browse the repository at this point in the history
  • Loading branch information
levimykel committed Oct 28, 2024
1 parent 6a5eb26 commit 00f8524
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/types/model/contentRelationship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ export interface CustomTypeModelContentRelationshipField<
customtypes?: readonly CustomTypeIDs[]
tags?: readonly Tags[]
allowText?: boolean
repeat?: boolean
}
}
1 change: 1 addition & 0 deletions src/types/model/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface CustomTypeModelLinkField {
| (typeof CustomTypeModelLinkSelectType)[keyof typeof CustomTypeModelLinkSelectType]
allowText?: boolean
allowTargetBlank?: boolean
repeat?: boolean
}
}

Expand Down
1 change: 1 addition & 0 deletions src/types/model/linkToMedia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ export interface CustomTypeModelLinkToMediaField {
placeholder?: string
select: typeof CustomTypeModelLinkSelectType.Media
allowText?: boolean
repeat?: boolean
}
}
24 changes: 24 additions & 0 deletions test/types/customType-contentRelationship.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,30 @@ expectType<prismic.CustomTypeModelContentRelationshipField<string, "foo">>({
},
})

/**
* Supports optional `allowText` property.
*/
expectType<prismic.CustomTypeModelContentRelationshipField<string, "foo">>({
type: prismic.CustomTypeModelFieldType.Link,
config: {
label: "string",
select: prismic.CustomTypeModelLinkSelectType.Document,
allowText: true,
},
})

/**
* Supports optional `repeat` value.
*/
expectType<prismic.CustomTypeModelContentRelationshipField<string, "foo">>({
type: prismic.CustomTypeModelFieldType.Link,
config: {
label: "string",
select: prismic.CustomTypeModelLinkSelectType.Document,
repeat: false,
},
})

/**
* `@prismicio/types` extends `@prismicio/types-internal`
*/
Expand Down
13 changes: 12 additions & 1 deletion test/types/customType-link.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ expectType<prismic.CustomTypeModelLinkField>({
})

/**
* Supports optional `text` property.
* Supports optional `allowText` property.
*/
expectType<prismic.CustomTypeModelLinkField>({
type: prismic.CustomTypeModelFieldType.Link,
Expand All @@ -71,6 +71,17 @@ expectType<prismic.CustomTypeModelLinkField>({
},
})

/**
* Supports optional `repeat` property.
*/
expectType<prismic.CustomTypeModelLinkField>({
type: prismic.CustomTypeModelFieldType.Link,
config: {
label: "string",
repeat: true,
},
})

/**
* `@prismicio/types` extends `@prismicio/types-internal`
*/
Expand Down
14 changes: 13 additions & 1 deletion test/types/customType-linkToMedia.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ expectType<prismic.CustomTypeModelLinkToMediaField>({
})

/**
* Supports optional `text` property.
* Supports optional `allowText` property.
*/
expectType<prismic.CustomTypeModelLinkToMediaField>({
type: prismic.CustomTypeModelFieldType.Link,
Expand All @@ -52,6 +52,18 @@ expectType<prismic.CustomTypeModelLinkToMediaField>({
},
})

/**
* Supports optional `repeat` property.
*/
expectType<prismic.CustomTypeModelLinkToMediaField>({
type: prismic.CustomTypeModelFieldType.Link,
config: {
label: "string",
select: prismic.CustomTypeModelLinkSelectType.Media,
repeat: true,
},
})

/**
* `@prismicio/types` extends `@prismicio/types-internal`
*/
Expand Down

0 comments on commit 00f8524

Please sign in to comment.