(srcSet: string, resolveOpts: MarkdownResolveOpts)
| 173 | }; |
| 174 | |
| 175 | export const resolveSrcSet = async (srcSet: string, resolveOpts: MarkdownResolveOpts): Promise<string> => { |
| 176 | if (!srcSet) return null; |
| 177 | |
| 178 | // Parse the srcset |
| 179 | const candidates = parseSrcSet(srcSet); |
| 180 | |
| 181 | // Resolve each URL in the array of candidates |
| 182 | const resolvedCandidates = await Promise.all( |
| 183 | candidates.map(async (candidate) => { |
| 184 | const resolvedUrl = await resolveRemoteFile(candidate.url, resolveOpts); |
| 185 | return { |
| 186 | ...candidate, |
| 187 | url: resolvedUrl, |
| 188 | }; |
| 189 | }) |
| 190 | ); |
| 191 | |
| 192 | // Reconstruct the srcset string |
| 193 | return resolvedCandidates |
| 194 | .map((candidate) => { |
| 195 | let part = candidate.url; |
| 196 | if (candidate.w) part += ` ${candidate.w}w`; |
| 197 | if (candidate.h) part += ` ${candidate.h}h`; |
| 198 | if (candidate.d) part += ` ${candidate.d}x`; |
| 199 | return part; |
| 200 | }) |
| 201 | .join(", "); |
| 202 | }; |
no test coverage detected