(
currentRepo: {owner?: string; name?: string},
element: HTMLElement,
options: Partial<LinkifyIssuesOptions> = {},
)
| 83 | } |
| 84 | |
| 85 | export function linkifyIssues( |
| 86 | currentRepo: {owner?: string; name?: string}, |
| 87 | element: HTMLElement, |
| 88 | options: Partial<LinkifyIssuesOptions> = {}, |
| 89 | ): void { |
| 90 | const linkified = linkifyIssuesToDom(element.textContent, { |
| 91 | user: currentRepo.owner ?? '/', |
| 92 | repository: currentRepo.name ?? '/', |
| 93 | baseUrl: '', |
| 94 | ...options, |
| 95 | attributes: { |
| 96 | class: linkifiedUrlClass, // Necessary to avoid also shortening the links |
| 97 | ...options.attributes, |
| 98 | }, |
| 99 | }); |
| 100 | if (linkified.children.length === 0) { // Children are <a> |
| 101 | return; |
| 102 | } |
| 103 | |
| 104 | // Enable native issue title fetch |
| 105 | for (const link of linkified.children as HTMLCollectionOf<HTMLAnchorElement>) { |
| 106 | const issue = link.href.split('/').pop(); |
| 107 | link.setAttribute('class', 'issue-link js-issue-link'); |
| 108 | link.dataset.errorText = 'Failed to load title'; |
| 109 | link.dataset.permissionText = 'Title is private'; |
| 110 | link.dataset.url = link.href; |
| 111 | link.dataset.id = `rgh-issue-${issue!}`; |
| 112 | link.dataset.hovercardType = 'issue'; |
| 113 | link.dataset.hovercardUrl = `${link.pathname}/hovercard`; |
| 114 | } |
| 115 | |
| 116 | zipTextNodes(element, linkified); |
| 117 | repositionAnchors(element); |
| 118 | } |
| 119 | |
| 120 | export function linkifyUrls(element: HTMLElement): void { |
| 121 | if (element.textContent.length < 15) { // Must be long enough for a URL |
no test coverage detected