Open uhooi opened 2 years ago
OG データをダウンロードして、自前でレンダリングする必要があるかも。
その場合は OpenGraphDataDownloader
が使えそう。
ref: https://github.com/marty-suzuki/URLEmbeddedView#opengraphdatadownloader
CSS が得意じゃないから、自前でレンダリングは少し厳しい、、 OG カード表示の CSS がオープンソースであればいいんだけど、、
macOS インスタンスを使うとすれば、LinkPresentation を使うだけで情報の取得は可能ですね。
import LinkPresentation
try await run(originalURL: URL(string: "https://github.com/treastrain/tretjapannfcreader")!)
@MainActor
func run(originalURL: URL) async throws {
let metadataProvider = LPMetadataProvider()
let metadata = try await metadataProvider.startFetchingMetadata(for: originalURL)
// https://github.com/treastrain/TRETJapanNFCReader
let url = metadata.url
// https://github.com/treastrain/tretjapannfcreader
let originalURL = metadata.originalURL
// "treastrain/TRETJapanNFCReader: NFC (FeliCa) Reader for iOS 13 later Core NFC / Japanese e-Money prepaid or identification cards"
let title = metadata.title
let icon = try await metadata.iconProvider?.loadItem(forTypeIdentifier: "public.image") as! Data
let image = try await metadata.imageProvider?.loadItem(forTypeIdentifier: "public.image") as! Data
}
そんなフレームワークあるのwww そしたら OSS を使わずに済むかも…。 あ、でも Linux ではつかえないのか、、GitHub Actions だと macOS で Swift 5.6 がまだ使えないのがやっかい、、、
あ、でも Linux ではつかえないのか、、GitHub Actions だと macOS で Swift 5.6 がまだ使えないのがやっかい、、、
あっ それなのですが、すでに ios_osushi 下のリポジトリでは使えるようにしていただいております… https://github.com/ios-osushi/release-subscriptions/actions/runs/2258428022
概要
URL を OGP カード表示したい。