We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When generating fields with the widget datetime I'd like them to be typed as Date because gray-matter automatically parses these fields to Date.
datetime
Example Netlify config.yml:
collections: - label: "Blog" name: "blog" fields: - { label: "Published date", name: "publishedDate", widget: "datetime", required: true, }
Generated types:
export interface Blog { publishedDate: string; }
Desired generated type:
export interface Blog { publishedDate: Date; }
My setup:
"gray-matter": "^4.0.3", "netlify-ts": "^2.0.0",
The text was updated successfully, but these errors were encountered:
I've thought about adding support for defining types for custom widgets, and in this case override existing widget types.
Regarding your issue, to get the correct types you could use the JSON_SCHEMA when parsing the markdown files, which parses dates into strings:
JSON_SCHEMA
import yaml from "js-yaml"; matter(markdown, { engines: { yaml: (input) => yaml.load(input, { schema: yaml.JSON_SCHEMA }), }, });
Sorry, something went wrong.
Ah thanks, yeah that would work
No branches or pull requests
When generating fields with the widget
datetime
I'd like them to be typed as Date because gray-matter automatically parses these fields to Date.Example Netlify config.yml:
Generated types:
Desired generated type:
My setup:
The text was updated successfully, but these errors were encountered: