| 35 | } |
| 36 | |
| 37 | function defaultHtmlContent({ userCalendars }: { userCalendars: Calendar[] }) { |
| 38 | return html` |
| 39 | <main id="main"> |
| 40 | <section id="calendars"> |
| 41 | ${Loading()} |
| 42 | </section> |
| 43 | </main> |
| 44 | |
| 45 | <script type="module"> |
| 46 | import { h, render, Fragment } from 'preact'; |
| 47 | |
| 48 | // Imported files need some preact globals to work |
| 49 | window.h = h; |
| 50 | window.Fragment = Fragment; |
| 51 | |
| 52 | import Calendars from '/public/components/calendar/Calendars.js'; |
| 53 | |
| 54 | const calendarsElement = document.getElementById('calendars'); |
| 55 | |
| 56 | if (calendarsElement) { |
| 57 | const calendarsApp = h(Calendars, { |
| 58 | initialCalendars: ${JSON.stringify(userCalendars || [])}, |
| 59 | }); |
| 60 | |
| 61 | render(calendarsApp, calendarsElement); |
| 62 | |
| 63 | document.getElementById('loading')?.remove(); |
| 64 | } |
| 65 | </script> |
| 66 | `; |
| 67 | } |
| 68 | |
| 69 | export default page({ |
| 70 | get, |