--- import SubpageLayout from '../layouts/SubpageLayout.astro'; import { getAllegatiCodiceEtico } from '../data/allegati-codice-etico'; const path = Astro.url.pathname; const localeMatch = path.match(/^\/(en|th)(\/|$)/); const currentLocale = (localeMatch?.[1] ?? 'it') as 'it' | 'en' | 'th'; const a = getAllegatiCodiceEtico(currentLocale); const { page, allegati } = a; const link = 'text-sky-400/90 underline-offset-2 hover:text-sky-300 hover:underline'; const isLabeledFields = (item: unknown): item is { label: string; fields: string[] } => typeof item === 'object' && item !== null && 'label' in item && 'fields' in item; const isLabeledText = (item: unknown): item is { label: string; text: string } => typeof item === 'object' && item !== null && 'label' in item && 'text' in item; ---

{page.backLabel}

{ allegati.map((allegato) => (

{allegato.heading}

{allegato.description}

{allegato.intro ? (

{allegato.intro}

) : null}
{ allegato.sections.map((section) => (
{section.title ? (

{section.title}

) : null} {section.intro ? (

{section.intro}

) : null} {Array.isArray(section.content) ? ( section.content.length > 0 && typeof section.content[0] === 'string' ? (
    {(section.content as string[]).map((item) => (
  • {item}
  • ))}
) : section.content.length > 0 && isLabeledFields(section.content[0]) ? (
{(section.content as { label: string; fields: string[] }[]).map((item) => (
{item.label}
{item.fields.join(' | ')}
))}
) : section.content.length > 0 && isLabeledText(section.content[0]) ? (
{(section.content as { label: string; text: string }[]).map((item) => (
{item.label}
{item.text}
))}
) : (

{String(section.content)}

) ) : (

{String(section.content)}

)} {section.note ? (

{section.note}

) : null}
)) }
{allegato.footer ? (

{allegato.footer}

) : null}
)) }