-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feat/namespace
- Loading branch information
Showing
13 changed files
with
279 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
import { Field } from "contentful" | ||
import renderInterfaceProperty from "../typescript/renderInterfaceProperty" | ||
|
||
export default function renderField(field: Field, type: string): string { | ||
return renderInterfaceProperty(field.id, type, field.required, field.name) | ||
export default function renderField( | ||
field: Field, | ||
type: string, | ||
localization: boolean = false, | ||
): string { | ||
return renderInterfaceProperty(field.id, type, field.required, localization, field.name) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** renders helper types for --localization flag */ | ||
export default function renderLocalizedTypes(localization: boolean) { | ||
if (!localization) return null | ||
|
||
return ` | ||
export type LocalizedField<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 | ||
} | ||
` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.