Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const getSourceProps = (
{ language, code, id }: SourceProps,
{ id: currentId, storyStore }: DocsContextProps
): PureSourceProps => {
let source = code; // prefer user-specified code
if (!source) {
const targetId = id || currentId; // prefer user-specified story id
const { parameters } = storyStore.fromId(targetId);
if (parameters) {
const { mdxSource, storySource } = parameters;
source = mdxSource || (storySource && extract(targetId, storySource));
}
}
return source
? { code: source, language: language || 'jsx' }
: { error: SourceError.SOURCE_UNAVAILABLE };
};