File tree Expand file tree Collapse file tree 2 files changed +28
-15
lines changed
packages/frontend/src/help Expand file tree Collapse file tree 2 files changed +28
-15
lines changed Original file line number Diff line number Diff line change 11import { useParams } from "@solidjs/router" ;
2- import { lazy } from "solid-js" ;
2+ import { createResource , Show } from "solid-js" ;
33import { Dynamic } from "solid-js/web" ;
44
55import { guidesList } from "./guides" ;
@@ -14,19 +14,27 @@ export default function GuideHelpPage() {
1414export function GuideHelp ( props : { id ?: string } ) {
1515 // Note that guide should never be undefined, due to existingGuideFilter
1616 // in routes.ts
17- const guide = guidesList . find ( ( item ) => item . id === props . id ) ;
17+ const guide = ( ) => guidesList . find ( ( item ) => item . id === props . id ) ;
18+
19+ const [ content ] = createResource (
20+ ( ) => props . id ,
21+ async ( guideId ) => {
22+ if ( ! guideId ) {
23+ return null ;
24+ }
25+ return await import ( `./guide/${ guideId } .mdx` ) ;
26+ } ,
27+ ) ;
1828
1929 return (
2030 < >
2131 < h1 >
22- < a href = "/help/guides/" > Guides</ a > / { guide ?. title }
32+ < a href = "/help/guides/" > Guides</ a > / { guide ( ) ?. title }
2333 </ h1 >
2434 < p >
25- < i > { guide ?. description } </ i >
35+ < i > { guide ( ) ?. description } </ i >
2636 </ p >
27- < Dynamic component = { helpGuideContent ( props . id ) } />
37+ < Show when = { content ( ) } > { ( module ) => < Dynamic component = { module ( ) . default } /> } </ Show >
2838 </ >
2939 ) ;
3040}
31-
32- const helpGuideContent = ( id ?: string ) => lazy ( ( ) => import ( `./guide/${ id } .mdx` ) ) ;
Original file line number Diff line number Diff line change @@ -22,13 +22,16 @@ export default function LogicHelpPage() {
2222}
2323
2424function LogicHelpDetail ( props : { theory : Theory } ) {
25- const Content = lazy ( async ( ) => {
26- try {
27- return await import ( `./logics/${ props . theory . id } .mdx` ) ;
28- } catch {
29- return { default : LogicHelpNotFound } ;
30- }
31- } ) ;
25+ const [ content ] = createResource (
26+ ( ) => props . theory . id ,
27+ async ( theoryId ) => {
28+ try {
29+ return await import ( `./logics/${ theoryId } .mdx` ) ;
30+ } catch {
31+ return { default : LogicHelpNotFound } ;
32+ }
33+ } ,
34+ ) ;
3235
3336 return (
3437 < >
@@ -73,7 +76,9 @@ function LogicHelpDetail(props: { theory: Theory }) {
7376 </ Show >
7477 </ div >
7578 </ Show >
76- < Content theory = { props . theory } />
79+ < Show when = { content ( ) } >
80+ { ( module ) => < Dynamic component = { module ( ) . default } theory = { props . theory } /> }
81+ </ Show >
7782 </ >
7883 ) ;
7984}
You can’t perform that action at this time.
0 commit comments