type WidgetParam = { name: string; connector?: boolean; }; export function createDocumentationLink({ name, connector = false, }: WidgetParam): string { return [ 'https://www.algolia.com/doc/api-reference/widgets/', name, '/js/', connector ? '#connector' : '', ].join(''); } type DocumentationMessageGenerator = (message?: string) => string; export function createDocumentationMessageGenerator( ...widgets: WidgetParam[] ): DocumentationMessageGenerator { const links = widgets .map((widget) => createDocumentationLink(widget)) .join(', '); return (message?: string) => [message, `See documentation: ${links}`].filter(Boolean).join('\n\n'); }