fix: resolve header image paths in production build

- Add import.meta.glob to process header images in PostCard component
- Replace manual URL construction with Vite's asset handling
- Ensures images load correctly in both dev and production environments
This commit is contained in:
2025-09-28 14:11:55 -05:00
parent 3450239fe4
commit 36670fd528

View File

@@ -3,10 +3,12 @@ import React from 'react';
import { Button } from '@progress/kendo-react-buttons'; import { Button } from '@progress/kendo-react-buttons';
import { Card, CardImage, CardBody } from '@progress/kendo-react-layout'; import { Card, CardImage, CardBody } from '@progress/kendo-react-layout';
// Import all header images so Vite processes them
const headerImages = import.meta.glob('../../assets/header/*', { eager: true });
const PostCard = ({ post, onEdit }) => { const PostCard = ({ post, onEdit }) => {
const dataPath = post.header.image; const dataPath = post.header.image;
const relativePath = `../../${dataPath}`; const imageUrl = headerImages[`../../${dataPath}`]?.default || dataPath;
const imageUrl = new URL(relativePath, import.meta.url).href;
const formatDate = (utcString) => { const formatDate = (utcString) => {
if (!utcString) return ''; if (!utcString) return '';