({ userArticles }: { userArticles: NewsFeedArticle[] })
| 30 | } |
| 31 | |
| 32 | function defaultHtmlContent({ userArticles }: { userArticles: NewsFeedArticle[] }) { |
| 33 | return html` |
| 34 | <main id="main"> |
| 35 | <section id="articles"> |
| 36 | ${Loading()} |
| 37 | </section> |
| 38 | </main> |
| 39 | |
| 40 | <script type="module"> |
| 41 | import { h, render, Fragment } from 'preact'; |
| 42 | |
| 43 | // Imported files need some preact globals to work |
| 44 | window.h = h; |
| 45 | window.Fragment = Fragment; |
| 46 | |
| 47 | import Articles from '/public/components/news/Articles.js'; |
| 48 | |
| 49 | const articlesElement = document.getElementById('articles'); |
| 50 | |
| 51 | if (articlesElement) { |
| 52 | const articlesApp = h(Articles, { |
| 53 | initialArticles: ${serializeForInlineScript(userArticles || [])}, |
| 54 | }); |
| 55 | |
| 56 | render(articlesApp, articlesElement); |
| 57 | |
| 58 | document.getElementById('loading')?.remove(); |
| 59 | } |
| 60 | </script> |
| 61 | `; |
| 62 | } |
| 63 | |
| 64 | export default page({ |
| 65 | get, |
no test coverage detected