PageSourceSearch

https://pagecord.com/assets/controllers/media_embeds_controller-f5b20285.js

js pagecord.com collected 2026-10-03 19:24:40 UTC 854 bytes, 29 lines download raw bytes

1import { Controller } from "@hotwired/stimulus"
2import { isEmbeddableLink, mediaSites } from "media_sites"
3
4export default class extends Controller {
5  connect() {
6    this.mediaSites = mediaSites()
7    this.replaceMediaLinks()
8  }
9
10  async replaceMediaLinks() {
11    const articles = Array.from(this.element.querySelectorAll('article'))
12    const links = articles.flatMap(a => Array.from(a.querySelectorAll('a')).filter(l => isEmbeddableLink(l, this.mediaSites)))
13    await Promise.all(links.map(link => this.processLink(link)))
14  }
15
16  async processLink(link) {
17    const url = link.href
18
19    for (const site of this.mediaSites) {
20      if (site.regex.test(url)) {
21        const iframe = await site.transform(url)
22        if (iframe) {
23          link.replaceWith(iframe)
24          break // Stop after first successful match
25        }
26      }
27    }
28  }
29}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.