mirror of
https://github.com/tauri-apps/tauri-docs.git
synced 2026-01-31 00:35:16 +01:00
add fallback for sponsors images (#3554)
This commit is contained in:
BIN
src/assets/fallback.jpg
Normal file
BIN
src/assets/fallback.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
@@ -2,6 +2,7 @@
|
||||
import { Image } from 'astro:assets';
|
||||
import { OC_IMAGE_DIMENSION } from 'packages/fetch-sponsors/config';
|
||||
import { type OpenCollectiveSponsor as Sponsor } from 'packages/fetch-sponsors/types';
|
||||
import fallbackImage from 'src/assets/fallback.jpg';
|
||||
|
||||
interface Props {
|
||||
sponsor: Sponsor;
|
||||
@@ -18,6 +19,11 @@ const roundingStyle: Record<Sponsor['type'], string> = {
|
||||
function getUrl(sponsor: Sponsor): string {
|
||||
return `${sponsor.socialLinks?.website ?? sponsor.profileUrl}?ref=tauri.app&utm_source=tauri.app`;
|
||||
}
|
||||
|
||||
const res = await fetch(sponsor.avatarUrl, { method: 'HEAD' });
|
||||
if (res && !res.ok) {
|
||||
sponsor.avatarUrl = fallbackImage.src;
|
||||
}
|
||||
---
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user