import { render } from 'hono/jsx/dom'
import { App, route } from './app'

const root = document.getElementById('root')

// Initial render
if (root) {
  render(<App />, root)
}

// On route change, re-render the whole app to update nav state
function updateApp() {
  if (root) {
    render(<App />, root)
  }
}

window.addEventListener('routechange', updateApp)
window.addEventListener('popstate', updateApp)
