jtormey / lax

A minimal Slack clone built with Elixir & Phoenix LiveView
50 stars 5 forks source link

Support unfurling links in messages #7

Open jtormey opened 1 month ago

jtormey commented 1 month ago

I implemented this a while back and can likely reuse much of this code: https://github.com/93software/lynx

carson-katri commented 1 month ago

iOS has the Link Presentation framework, which could be used to display link previews.

It provides the LPLinkView, which is a UIKit UIView that could be wrapped with a UIViewRepresentable to include in SwiftUI.

image

jtormey commented 1 month ago

That's cool, does this fetch the link every time the view is rendered?

On web, the way I've done this in the past is to have a background process request data for the link, then store those results in the database and render them underneath the message.

carson-katri commented 1 month ago

You can cache the LPLinkMetadata however you want in your app. But if you're driving it with server-side data, you can construct the LPLinkMetadata from your own values and still use LPLinkView for the UI.