UNPKG

@redocly/theme

Version:

Shared UI components lib

10 lines (9 loc) 409 B
/** * Utility function for use in React frontmatter * This function creates a string that will be processed by the frontmatter loader * to convert it into a translation key object */ export const frontmatterTranslate = (key: string, defaultValue: string): string => { const escapedDefaultValue = defaultValue.replace(/'/g, "\\'"); return `frontmatterTranslate('${key}', '${escapedDefaultValue}')`; };