@@ -72,23 +72,9 @@ export class InterfacePlugin extends StarbasePlugin {
7272 content = "width=device-width, initial-scale=1"
7373 name = "viewport"
7474 />
75- < title > Starbase + Hono </ title >
75+ < title > StarbaseDB </ title >
7676 < link rel = "icon" href = "/favicon.svg" />
7777
78- < script
79- dangerouslySetInnerHTML = { {
80- __html : `
81- // Check theme on page load
82- const theme = document.cookie
83- .split('; ')
84- .find(row => row.startsWith('theme='))
85- ?.split('=')[1];
86- if (theme === 'dark') {
87- document.documentElement.classList.add('dark');
88- }
89- ` ,
90- } }
91- />
9278 < Style />
9379 { assetImportTags }
9480 </ head >
@@ -101,60 +87,17 @@ export class InterfacePlugin extends StarbasePlugin {
10187 )
10288 )
10389
90+ // An example route and page definition to show you how to add new pages.
91+ // page - declares how a user will access this page
92+ // page - maps to a folder name in `./pages/${name}/index.tsx
93+ // data-client - maps to the same name as the page above
10494 this . registerRoute (
10595 app ,
10696 { path : '/template' , page : 'template' } ,
10797 ( c ) => {
10898 return c . render ( < div id = "root" data-client = "template" > </ div > )
10999 }
110100 )
111-
112- this . registerRoute ( app , { path : '/' , page : 'page1' } , ( c ) => {
113- // `data-client` value must match the name of the folder the page component is contained within.
114- return c . render ( < div id = "root" data-client = "page1" > </ div > )
115- } )
116-
117- this . registerRoute ( app , { path : '/1' , page : 'page1' } , ( c ) => {
118- // Multiple routes can reference the same component
119- return c . render ( < div id = "root" data-client = "page1" > </ div > )
120- } )
121-
122- this . registerRoute ( app , { path : '/2' , page : 'page2' } , async ( c ) => {
123- // We can query the database before responding with any server data to render a page
124- const result = ( await this . dataSource ?. rpc . executeQuery ( {
125- sql : `SELECT COUNT(*) as count FROM user LIMIT ?` ,
126- params : [ 25 ] ,
127- } ) ) as Record < string , any > [ ]
128-
129- const serverData = {
130- initialCount : result [ 0 ] . count ,
131- message : `You have ${ result [ 0 ] . count } users registered` ,
132- }
133-
134- // We can pass data from the server to our components by utilizing `data-server-props`
135- return c . render (
136- < div
137- id = "root"
138- data-client = "page2"
139- data-server-props = { JSON . stringify ( serverData ) }
140- > </ div >
141- )
142- } )
143-
144- this . registerRoute ( app , { path : '/home' , page : 'home' } , ( c ) => {
145- return c . render ( < div id = "root" data-client = "home" > </ div > )
146- } )
147-
148- this . registerRoute ( app , { path : '/chat/:id' , page : 'chat' } , ( c ) => {
149- const { id } = c . req . param ( )
150- return c . render (
151- < div
152- id = "root"
153- data-client = "chat"
154- data-server-props = { JSON . stringify ( { id } ) }
155- > </ div >
156- )
157- } )
158101 }
159102
160103 public get supportedRoutes ( ) : string [ ] {
0 commit comments