import type { CustomContentTypes } from './CustomContent.types' import customContentRaw from './custom-content.json' const customContentStaticObj = customContentRaw as Omit export type CustomContent = keyof typeof customContentStaticObj type SnakeToCamelCase = S extends `${infer First}_${infer Rest}` ? `${First}${SnakeToCamelCase>}` : S type CustomContentToCamelCase = S extends `${infer P}:${infer R}` ? `${SnakeToCamelCase

}${Capitalize>}` : SnakeToCamelCase function contentToCamelCase(feature: CustomContent) { return feature .replace(/:/g, '_') .split('_') .map((word, index) => (index === 0 ? word : word[0].toUpperCase() + word.slice(1))) .join('') as CustomContentToCamelCase } type CustomContentResult = { [key in CustomContentToCamelCase extends keyof CustomContentTypes ? CustomContentToCamelCase : never]: CustomContentTypes[key] | null } export const getCustomContent = ( contents: T ): CustomContentResult => { return Object.fromEntries( contents.map((content) => [contentToCamelCase(content), customContentStaticObj[content]]) ) as CustomContentResult }