| 51 | } |
| 52 | |
| 53 | function defaultHtmlContent({ userDirectories, userPhotos, currentPath }: { |
| 54 | userDirectories: Directory[]; |
| 55 | userPhotos: DirectoryFile[]; |
| 56 | currentPath: string; |
| 57 | }) { |
| 58 | return html` |
| 59 | <main id="main"> |
| 60 | <section id="main-photos"> |
| 61 | ${Loading()} |
| 62 | </section> |
| 63 | </main> |
| 64 | |
| 65 | <script type="module"> |
| 66 | import { h, render, Fragment } from 'preact'; |
| 67 | |
| 68 | // Imported files need some preact globals to work |
| 69 | window.h = h; |
| 70 | window.Fragment = Fragment; |
| 71 | |
| 72 | import MainPhotos from '/public/components/photos/MainPhotos.js'; |
| 73 | |
| 74 | const mainPhotosElement = document.getElementById('main-photos'); |
| 75 | |
| 76 | if (mainPhotosElement) { |
| 77 | const mainPhotosApp = h(MainPhotos, { |
| 78 | initialDirectories: ${JSON.stringify(userDirectories || [])}, |
| 79 | initialFiles: ${JSON.stringify(userPhotos || [])}, |
| 80 | initialPath: ${JSON.stringify(currentPath)}, |
| 81 | }); |
| 82 | |
| 83 | render(mainPhotosApp, mainPhotosElement); |
| 84 | |
| 85 | document.getElementById('loading')?.remove(); |
| 86 | } |
| 87 | </script> |
| 88 | `; |
| 89 | } |
| 90 | |
| 91 | export default page({ |
| 92 | get, |