--- import type { HTMLTag } from 'astro/types' import Icon from './Icon.astro' /** alert-{color} — matches defaultIcons below */ type AlertColor = 'success' | 'warning' | 'danger' | 'info' interface Props { color?: AlertColor /** alert-important (filled) / alert-minor (borderless) style variants */ variant?: 'important' | 'minor' showClose?: boolean class?: string title?: string /** heading level for the title; match it to the surrounding context */ titleAs?: HTMLTag description?: string list?: string[] action?: string link?: string /** remaining attributes (id, data-*, aria-*, …) are forwarded to the root element */ [key: string]: unknown } const { color = 'success', variant, showClose, class: className, title, titleAs: Title = 'h3', description, list, action, link, ...rest } = Astro.props const defaultIcons: Record = { success: 'check', warning: 'alert-triangle', danger: 'alert-circle', info: 'info-circle', } const icon = defaultIcons[color] const classes = ['alert', variant && `alert-${variant}`, `alert-${color}`, showClose && 'alert-dismissible', className] --- {icon && } { description || list ? ( {/* set:html preserves entities like … in the title */} {title && } {list && list.length > 0 && ( {list.map((item) => ( {item} ))} )} ) : ( {/* prettier-ignore — anchor on one line (whitespace ends up in the code panel) */} {action ? ( {action} ) : link ? ( {link} ) : null} ) } {showClose && }