(markdownPath)
| 900 | } |
| 901 | |
| 902 | function getCover(markdownPath) { |
| 903 | if (coverCache.has(markdownPath)) { |
| 904 | return coverCache.get(markdownPath); |
| 905 | } |
| 906 | |
| 907 | var request = fetch(markdownPath + '?v=20260531-card-cover', { |
| 908 | cache: 'force-cache' |
| 909 | }) |
| 910 | .then(function (response) { |
| 911 | if (!response.ok) { |
| 912 | return ''; |
| 913 | } |
| 914 | |
| 915 | return response.text(); |
| 916 | }) |
| 917 | .then(function (markdown) { |
| 918 | return extractFirstImage(markdown, markdownPath); |
| 919 | }) |
| 920 | .catch(function () { |
| 921 | return ''; |
| 922 | }); |
| 923 | |
| 924 | coverCache.set(markdownPath, request); |
| 925 | return request; |
| 926 | } |
| 927 | |
| 928 | function extractFirstImage(markdown, markdownPath) { |
| 929 | var imagePattern = /!\[[^\]]*]\(([^)\s]+)(?:\s+["'][^"']*["'])?\)|<img[^>]+src=["']([^"']+)["'][^>]*>/ig; |
no test coverage detected