import { renderHTML } from "./bud/view/_ssr_runtime.ts"
{{- range $view := $.Views }}
import {{$view.Page.Pascal}} from "./bud/{{$view.Page}}"
{{- end }}

const views = {}
{{- range $view := $.Views }}
views["{{$view.Route}}"] = {{ $view.Page.Pascal }}
{{- end }}

// Render the view
export function render(route, props, context) {
  const view = views[route]
  if (!view) {
    return JSON.stringify({
      status: 404
    })
  }
  return JSON.stringify(renderHTML({
    context: context,
    props: props,
    route: route,
    view: view,
  }))
}
