@@ -31,7 +31,7 @@ function DndEpisodePage() {
3131 const { bookId, episodeId } = useParams ( ) ; // Get bookId as well
3232 const { setBgImageName, setBreadcrumbs } = useContext ( DndContext ) ; // Get setBgImageName and setBreadcrumbs from context
3333 const [ episodeContent , setEpisodeContent ] = useState ( '' ) ;
34- const [ episodeTitle , setEpisodeTitle ] = useState ( 'Loading Episode... ' ) ;
34+ const [ episodeTitle , setEpisodeTitle ] = useState ( '' ) ;
3535 const [ book , setBook ] = useState ( null ) ; // State to store the current book
3636 const [ bgImage , setBgImage ] = useState ( '' ) ; // State for background image
3737
@@ -42,33 +42,6 @@ function DndEpisodePage() {
4242 setBgImageName ( parseWallpaperName ( randomImage . split ( '/' ) . pop ( ) ) ) ;
4343 } , [ setBgImageName ] ) ;
4444
45- useEffect ( ( ) => {
46- const fetchEpisodeContent = async ( ) => {
47- try {
48- const response = await fetch ( `${ process . env . PUBLIC_URL } /dnd/episode${ episodeId } .txt` ) ;
49- if ( ! response . ok ) {
50- throw new Error ( `HTTP error! status: ${ response . status } ` ) ;
51- }
52- const text = await response . text ( ) ;
53- setEpisodeContent ( text ) ;
54-
55- // Extract title from the first line of the content
56- const firstLine = text . split ( '\n' ) [ 0 ] ;
57- if ( firstLine ) {
58- setEpisodeTitle ( firstLine ) ;
59- } else {
60- setEpisodeTitle ( `Episode ${ episodeId } ` ) ;
61- }
62- } catch ( error ) {
63- console . error ( "Failed to fetch episode content:" , error ) ;
64- setEpisodeContent ( "Failed to load episode content. Please check the URL." ) ;
65- setEpisodeTitle ( "Episode Not Found" ) ;
66- }
67- } ;
68-
69- fetchEpisodeContent ( ) ;
70- } , [ episodeId ] ) ;
71-
7245 usePageTitle ( episodeTitle ) ;
7346
7447 const [ allBooks , setAllBooks ] = useState ( [ ] ) ; // Renamed from allEpisodes to allBooks
0 commit comments