import HTML struct HomeLink { let icon: String let title: String let description: String let href: String let linkType: LinkType enum LinkType { case `internal` case external } } extension HomeLink { static func `internal`( _ title: String, icon: String, href: String, description: String ) -> Self { self.init(icon: icon, title: title, description: description, href: href, linkType: .internal) } static func external( _ title: String, icon: String, href: String, description: String ) -> Self { self.init(icon: icon, title: title, description: description, href: href, linkType: .external) } } extension HomeLink: NodeConvertible { func asNode() -> Node { switch linkType { case .internal: return internalLink() case .external: return externalLink() } } private func internalLink() -> Node { a(class: "bg-orange-400 border-2 border-green-600 p-4 rounded-lg [&:hover]:bg-orange-500", href: href) { div(class: "flex text-3xl") { i(class: "mt-1", customAttributes: ["data-lucide": icon]) p(class: "ps-2") { title } } p(class: "text-sm") { description } } } private func externalLink() -> Node { a( class: "bg-orange-400 border-2 border-green-600 p-4 rounded-lg [&:hover]:bg-orange-500", href: href, rel: "nofollow", target: "_blank'" ) { div(class: "flex text-3xl") { i(class: "mt-1", customAttributes: ["data-lucide": icon]) p(class: "ps-2") { title } } p(class: "text-sm") { description } } } }