mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 11:42:17 +00:00
21 lines
659 B
TypeScript
21 lines
659 B
TypeScript
import { Index, Show, createMemo } from "solid-js"
|
|
import { linkSegments } from "./link-segments"
|
|
|
|
/** Plain text with every http(s) URL rendered as a link that opens outside the app. */
|
|
export function LinkedText(props: { text: string }) {
|
|
const segments = createMemo(() => linkSegments(props.text))
|
|
|
|
return (
|
|
<Index each={segments()}>
|
|
{(segment) => (
|
|
<Show when={segment().href} fallback={segment().text}>
|
|
{(href) => (
|
|
<a data-slot="linked-text-link" href={href()} target="_blank" rel="noopener noreferrer">
|
|
{segment().text}
|
|
</a>
|
|
)}
|
|
</Show>
|
|
)}
|
|
</Index>
|
|
)
|
|
}
|