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
component="img"
alt="green iguana"
image={article.img}
image={(
import.meta.env.VITE_API_BASE_URL.replace(/\/+$/, "") +
"/" +
(article.img?.replace(/^\/+/, "") || "")
)}
sx={{
height: { sm: 'auto', md: '50%' },
aspectRatio: { sm: '16 / 9', md: '' },

View File

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

View File

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

View File

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