| 34 | } |
| 35 | |
| 36 | function defaultHtmlContent({ userDashboard }: { userDashboard: Dashboard }) { |
| 37 | const initialNotes = userDashboard?.data?.notes || 'Jot down some notes here.'; |
| 38 | |
| 39 | return html` |
| 40 | <main id="main"> |
| 41 | ${Loading()} |
| 42 | <section id="links"></section> |
| 43 | <section id="notes"></section> |
| 44 | </main> |
| 45 | |
| 46 | <script type="module"> |
| 47 | import { h, render, Fragment } from 'preact'; |
| 48 | |
| 49 | // Imported files need some preact globals to work |
| 50 | window.h = h; |
| 51 | window.Fragment = Fragment; |
| 52 | |
| 53 | import Links from '/public/components/dashboard/Links.js'; |
| 54 | import Notes from '/public/components/dashboard/Notes.js'; |
| 55 | |
| 56 | const linksElement = document.getElementById('links'); |
| 57 | const notesElement = document.getElementById('notes'); |
| 58 | |
| 59 | if (linksElement) { |
| 60 | const linksApp = h(Links, { initialLinks: ${JSON.stringify(userDashboard?.data?.links || [])} }); |
| 61 | |
| 62 | render(linksApp, linksElement); |
| 63 | } |
| 64 | |
| 65 | if (notesElement) { |
| 66 | const notesApp = h(Notes, { initialNotes: ${JSON.stringify(initialNotes)} }); |
| 67 | |
| 68 | render(notesApp, notesElement); |
| 69 | } |
| 70 | |
| 71 | if (linksElement && notesElement) { |
| 72 | document.getElementById('loading')?.remove(); |
| 73 | } |
| 74 | </script> |
| 75 | `; |
| 76 | } |
| 77 | |
| 78 | export default page({ |
| 79 | get, |