import articles from '@/data/articles.json'

type Block = {
  tag: string
  text: string
  strong: boolean
  italic: boolean
  indent: boolean
}

/**
 * A blogbejegyzések szövege az eredeti Symfony template-ekből
 * gépi kinyeréssel került át, hogy egyetlen karakter se változzon.
 */
export default function Article({ name }: { name: keyof typeof articles }) {
  const blocks = articles[name] as Block[]

  return (
    <div className="prose">
      {blocks.map((b, i) => {
        const style = b.indent ? { marginLeft: 20 } : undefined
        const content = b.strong ? <strong>{b.text}</strong> : b.italic ? <i>{b.text}</i> : b.text

        if (b.tag === 'h3') return <h3 key={i} className="text-center">{b.text}</h3>
        if (b.tag === 'h4') return <h4 key={i}>{content}</h4>
        if (b.tag === 'h6') return <h6 key={i}><i>{b.text}</i></h6>
        return <p key={i} style={style}>{content}</p>
      })}
    </div>
  )
}
