@@ -54,8 +54,30 @@ export async function loader({ context }: LoaderFunctionArgs) {
54
54
id : themes . nodes [ 0 ] . id . split ( "/" ) . pop ( ) ,
55
55
} ;
56
56
57
+ const themeRaw = {
58
+ rawQuizPageLiquid : "" ,
59
+ rawProductQuizJs : "" ,
60
+ } ;
61
+
57
62
// If the theme isn't Online Store 2.0, we need to fetch the raw files for the quiz page and JavaScript.
58
- if ( ! themes . nodes [ 0 ] . files . nodes . length ) theme . onlineStore2 = false ;
63
+ if ( ! themes . nodes [ 0 ] . files . nodes . length ) {
64
+ theme . onlineStore2 = false ;
65
+
66
+ const [ rawQuizPageLiquid , rawProductQuizJs ] = await Promise . all ( [
67
+ fs . readFile (
68
+ path . join ( process . cwd ( ) , "extensions" , "quiz" , "blocks" , "quiz.liquid" ) ,
69
+ "utf-8"
70
+ ) ,
71
+ fs . readFile (
72
+ path . join ( process . cwd ( ) , "extensions" , "quiz" , "assets" , "quiz.js" ) ,
73
+ "utf-8"
74
+ ) ,
75
+ ] ) ;
76
+
77
+ themeRaw . rawQuizPageLiquid = rawQuizPageLiquid ;
78
+
79
+ themeRaw . rawProductQuizJs = rawProductQuizJs ;
80
+ }
59
81
60
82
// Returns an object with the theme information and the shop domain.
61
83
return json ( {
@@ -66,14 +88,7 @@ export async function loader({ context }: LoaderFunctionArgs) {
66
88
domain : true ,
67
89
} ,
68
90
} ) ,
69
- rawQuizPageLiquid : await fs . readFile (
70
- path . join ( process . cwd ( ) , "extensions" , "quiz" , "blocks" , "quiz.liquid" ) ,
71
- "utf-8"
72
- ) ,
73
- rawProductQuizJs : await fs . readFile (
74
- path . join ( "extensions" , "quiz" , "assets" , "quiz.js" ) ,
75
- "utf-8"
76
- ) ,
91
+ ...themeRaw ,
77
92
} ) ;
78
93
}
79
94
0 commit comments