1- import { createAsync , type RouteDefinition , type RouteSectionProps } from "@solidjs/router" ;
2- import { For , Show } from "solid-js" ;
1+ import { type RouteDefinition , type RouteSectionProps } from "@solidjs/router" ;
2+ import { For , Show , createMemo } from "solid-js" ;
33import Comment from "~/components/comment" ;
44import { getStory } from "~/lib/api" ;
55
@@ -10,31 +10,29 @@ export const route = {
1010} satisfies RouteDefinition ;
1111
1212export default function Story ( props : RouteSectionProps ) {
13- const story = createAsync ( ( ) => getStory ( props . params . id ) ) ;
13+ const story = createMemo ( ( ) => getStory ( props . params . id ) ) ;
1414 return (
15- < Show when = { story ( ) } >
16- < div class = "item-view" >
17- < div class = "item-view-header" >
18- < a href = { story ( ) ! . url } target = "_blank" >
19- < h1 > { story ( ) ! . title } </ h1 >
20- </ a >
21- < Show when = { story ( ) ! . domain } >
22- < span class = "host" > ({ story ( ) ! . domain } )</ span >
23- </ Show >
24- < p class = "meta" >
25- { story ( ) ! . points } points | by < a href = { `/users/${ story ( ) ! . user } ` } > { story ( ) ! . user } </ a > { " " }
26- { story ( ) ! . time_ago } ago
27- </ p >
28- </ div >
29- < div class = "item-view-comments" >
30- < p class = "item-view-comments-header" >
31- { story ( ) ! . comments_count ? story ( ) ! . comments_count + " comments" : "No comments yet." }
32- </ p >
33- < ul class = "comment-children" >
34- < For each = { story ( ) ! . comments } > { comment => < Comment comment = { comment ( ) } /> } </ For >
35- </ ul >
36- </ div >
15+ < div class = "item-view" >
16+ < div class = "item-view-header" >
17+ < a href = { story ( ) . url } target = "_blank" >
18+ < h1 > { story ( ) . title } </ h1 >
19+ </ a >
20+ < Show when = { story ( ) . domain } >
21+ < span class = "host" > ({ story ( ) . domain } )</ span >
22+ </ Show >
23+ < p class = "meta" >
24+ { story ( ) . points } points | by < a href = { `/users/${ story ( ) . user } ` } > { story ( ) . user } </ a > { " " }
25+ { story ( ) . time_ago } ago
26+ </ p >
3727 </ div >
38- </ Show >
28+ < div class = "item-view-comments" >
29+ < p class = "item-view-comments-header" >
30+ { story ( ) . comments_count ? story ( ) . comments_count + " comments" : "No comments yet." }
31+ </ p >
32+ < ul class = "comment-children" >
33+ < For each = { story ( ) . comments } > { comment => < Comment comment = { comment ( ) } /> } </ For >
34+ </ ul >
35+ </ div >
36+ </ div >
3937 ) ;
4038}
0 commit comments