-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathrenderLocalizedTypes.ts
More file actions
31 lines (29 loc) · 957 Bytes
/
renderLocalizedTypes.ts
File metadata and controls
31 lines (29 loc) · 957 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/** renders helper types for --localization flag */
export default function renderLocalizedTypes(localization: boolean) {
if (!localization) return null
return `
export type DefaultLocalizedField<T> = Record<CONTENTFUL_DEFAULT_LOCALE_CODE, T>
export type LocalizedField<T> = DefaultLocalizedField<T> & Partial<Record<LOCALE_CODE, T>>
// We have to use our own localized version of Asset because of a bug in contentful https://github.com/contentful/contentful.js/issues/208
export interface Asset {
sys: Sys
fields: {
title: LocalizedField<string>
description: LocalizedField<string>
file: LocalizedField<{
url: string
details: {
size: number
image?: {
width: number
height: number
}
}
fileName: string
contentType: string
}>
}
toPlainObject(): object
}
`
}