-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
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
Feature request: Customize file name #164
Comments
Hi @tatemz |
@tatemz Create your own Renderer by extending The DefaultContentTypeRenderer and override the createContext method. Instead of returning the Context created by createDefaultContext, you could return the same context, but use a different implementation for the moduleName function. Finally you can set your new renderer when instantiating a new This should do the trick :) |
closing this for now |
Hey so I came back to this and my team and I ended up doing exactly what you suggested by extending the renderer. We actually made two versions, one generated the TS, and another generated Here's the sample output. We had to use import * as Contentful from 'contentful';
import * as Runtypes from 'runtypes';
import { Asset } from '../Asset';
export interface Author {
contentType: 'author';
authorName?: Contentful.EntryFields.Symbol;
authorImage?: Asset;
}
export const Author: Runtypes.Runtype<Author> = Runtypes.Lazy(() =>
Runtypes.Record({
authorName: Runtypes.Optional(Runtypes.String),
authorImage: Runtypes.Optional(Asset),
contentType: Runtypes.Literal('author'),
})
); Thanks for a great tool! |
@tatemz This seems to be a pretty cool use case 😍 Would you be interested to open a PR and add it to the project? |
Currently, it is not possible to override the file name
Can the
moduleName
function used here be from acontext
instead?The text was updated successfully, but these errors were encountered: