@@ -4,9 +4,8 @@ import Image from 'next/image';
44import Navbar from '../../components/Navbar' ;
55import Footer from '../../components/Footer' ;
66
7- import fs from 'node:fs/promises' ;
8- import path from 'node:path' ;
9- import Script from 'next/script' ;
7+ import { useEffect , useState } from 'react' ;
8+
109import { KevinContact } from '@/app/person-constants' ;
1110import { MENU_ITEMS as menuItems } from '../../constants' ;
1211
@@ -16,24 +15,21 @@ import ECSImage from '../../../public/knowledge-hub/ECS/ECS.jpg';
1615// Prefix for where the assets live under /public
1716const PUBLIC_PREFIX = '/knowledge-hub/ECS' ;
1817
19- async function loadHtml ( ) : Promise < string > {
20- // Read the prebuilt HTML from /public
21- const filePath = path . join ( process . cwd ( ) , 'public' , 'knowledge-hub' , 'ECS' , 'paper.html' ) ;
22- let html = await fs . readFile ( filePath , 'utf8' ) ;
23-
24- // --- Rewrite relative asset URLs so they work when embedded ---
25- // Matches src/href attributes that are relative (not starting with http(s)://, //, /, or #)
26- html = html . replace (
27- / \b ( s r c | h r e f ) = " ' ( [ ^ " ' ] + ) [ " ' ] / gi,
28- ( _m , attr , url ) => `${ attr } ="${ PUBLIC_PREFIX } /${ url } "`
29- ) ;
30-
31- return html ;
32- }
33-
18+ export default function Home ( ) {
19+ const [ html , setHtml ] = useState < string > ( '' ) ;
20+ useEffect ( ( ) => {
21+ fetch ( `${ PUBLIC_PREFIX } /paper.html` )
22+ . then ( r => r . text ( ) )
23+ . then ( t => {
24+ // Optionally rewrite relative URLs if needed
25+ const rewritten = t . replace (
26+ / \b ( s r c | h r e f ) = " ' ( [ ^ " ' ] + ) [ " ' ] / gi,
27+ ( _m , attr , url ) => `${ attr } ="${ PUBLIC_PREFIX } /${ url } "`
28+ ) ;
29+ setHtml ( rewritten ) ;
30+ } ) ;
31+ } , [ ] ) ;
3432
35- export default async function Home ( ) {
36- const HTML = await loadHtml ( ) ;
3733 return (
3834 < div >
3935 < Navbar menuItems = { menuItems } pageSelected = "" />
@@ -53,7 +49,7 @@ export default async function Home() {
5349 < a href = "https://doi.org/10.1016/j.simpat.2020.102243" > Vico: An entity-component-system based co-simulation framework</ a >
5450
5551 < main className = "prose max-w-none" >
56- < article dangerouslySetInnerHTML = { { __html : HTML } } />
52+ < article dangerouslySetInnerHTML = { { __html : html } } />
5753 </ main >
5854
5955 { /* Contact Section */ }
0 commit comments