@@ -5,6 +5,7 @@ import usePageTitle from '../utils/usePageTitle';
55import '../styles/dnd.css' ;
66import { DndContext } from '../context/DndContext' ; // Import DndContext
77import { parseWallpaperName } from '../utils/dndUtils' ; // Import parseWallpaperName
8+ import dndWallpapers from '../utils/dndWallpapers' ;
89import DndCard from '../components/DndCard' ; // Import DndCard
910import Slider from 'react-slick' ; // Import Slider
1011import 'slick-carousel/slick/slick.css' ; // Import slick-carousel CSS
@@ -31,9 +32,12 @@ const pageTransition = {
3132function DndLorePage ( ) {
3233 usePageTitle ( 'The Lore' ) ;
3334 const { setBgImageName, setBreadcrumbs } = useContext ( DndContext ) ; // Get setBgImageName and setBreadcrumbs from context
35+ const [ bgImage , setBgImage ] = useState ( '' ) ; // State for background image
3436
3537 useEffect ( ( ) => {
36- setBgImageName ( parseWallpaperName ( 'artem-sapegin-XGDBdSQ70O0-unsplash.jpg' ) ) ; // Set parsed name for the static background
38+ const randomImage = dndWallpapers [ Math . floor ( Math . random ( ) * dndWallpapers . length ) ] ;
39+ setBgImage ( randomImage ) ;
40+ setBgImageName ( parseWallpaperName ( randomImage . split ( '/' ) . pop ( ) ) ) ;
3741 setBreadcrumbs ( [
3842 { label : 'D&D Home' , path : '/dnd' } ,
3943 { label : 'The Lore' , path : '/dnd/lore' } ,
@@ -97,7 +101,7 @@ function DndLorePage() {
97101 transition = { pageTransition }
98102 className = "dnd-page-container"
99103 >
100- < div className = "dnd-hero" style = { { position : 'relative' } } >
104+ < div className = "dnd-hero" style = { { backgroundImage : `url( ${ process . env . PUBLIC_URL } ${ bgImage } )` , position : 'relative' } } >
101105 < h1 className = "dnd-title-box" >
102106 < span className = "dnd-hero-title-white" > The Lore</ span >
103107 </ h1 >
0 commit comments