prefixing BASE URL for images. will break existing hardcoded outside images

This commit is contained in:
2025-11-15 05:49:47 +05:30
parent ae0bc7dd12
commit d7e9827819
4 changed files with 20 additions and 9 deletions

View File

@@ -25,7 +25,11 @@ export default function ArticleCardSize4({
<CardMedia <CardMedia
component="img" component="img"
alt="green iguana" alt="green iguana"
image={article.img} image={(
import.meta.env.VITE_API_BASE_URL.replace(/\/+$/, "") +
"/" +
(article.img?.replace(/^\/+/, "") || "")
)}
sx={{ sx={{
height: { sm: 'auto', md: '50%' }, height: { sm: 'auto', md: '50%' },
aspectRatio: { sm: '16 / 9', md: '' }, aspectRatio: { sm: '16 / 9', md: '' },

View File

@@ -25,7 +25,11 @@ export default function ArticleCardSize6({
<CardMedia <CardMedia
component="img" component="img"
alt={article.title} alt={article.title}
image={article.img} image={(
import.meta.env.VITE_API_BASE_URL.replace(/\/+$/, "") +
"/" +
(article.img?.replace(/^\/+/, "") || "")
)}
sx={{ sx={{
aspectRatio: '16 / 9', aspectRatio: '16 / 9',
borderBottom: '1px solid', borderBottom: '1px solid',

View File

@@ -30,12 +30,11 @@ export function ArticleMeta({
<Avatar <Avatar
key={index} key={index}
alt={author.name} alt={author.name}
src={ src={(
(import.meta.env.VITE_API_BASE_URL.replace(/\/+$/, "") + import.meta.env.VITE_API_BASE_URL.replace(/\/+$/, "") +
"/" + "/" +
(author.avatar?.replace(/^\/+/, "") || "") (author.avatar?.replace(/^\/+/, "") || "")
) )}
}
sx={{ width: 24, height: 24 }} sx={{ width: 24, height: 24 }}
/> />
))} ))}

View File

@@ -75,7 +75,11 @@ function Author({ authors }: { authors: { name: string; avatar: string }[] }) {
<Avatar <Avatar
key={index} key={index}
alt={author.name} alt={author.name}
src={author.avatar} src={(
import.meta.env.VITE_API_BASE_URL.replace(/\/+$/, "") +
"/" +
(author.avatar?.replace(/^\/+/, "") || "")
)}
sx={{ width: 24, height: 24 }} sx={{ width: 24, height: 24 }}
/> />
))} ))}