import { Fragment } from 'react';

/**
 * Renders a string in which *asterisks* mark the emphasised part:
 * "Önce *dinleriz*." → Önce <em>dinleriz</em>.
 * Used for display headings (pair it with the `display-em` utility).
 */
export function Em({ text }: { text: string }) {
    return (
        <>
            {text
                .split('*')
                .map((part, index) =>
                    index % 2 === 1 ? (
                        <em key={index}>{part}</em>
                    ) : (
                        <Fragment key={index}>{part}</Fragment>
                    ),
                )}
        </>
    );
}
