1
1
// Load templates.
2
2
// @see https://vite.dev/guide/features.html#glob-import
3
3
// @see docs/custom-templates.md
4
- const templateModules = import . meta. glob ( '../templates/*.jsx' , { eager : true } )
5
- const customTemplatesModules = import . meta. glob ( '../custom-templates/*.jsx' , { eager : true } )
4
+ const templateModules = import . meta. glob ( "../templates/*.jsx" , { eager : true } ) ;
5
+ const customTemplatesModules = import . meta. glob ( "../custom-templates/*.jsx" , {
6
+ eager : true ,
7
+ } ) ;
6
8
7
9
function duckTypingTemplateModule ( module ) {
8
- return typeof ( module . id ) === "function" &&
9
- typeof ( module . config ) === "function" &&
10
- typeof ( module . renderSlide ) === "function" ;
10
+ return (
11
+ typeof module . id === "function" &&
12
+ typeof module . config === "function" &&
13
+ typeof module . renderSlide === "function"
14
+ ) ;
11
15
}
12
16
13
17
function findModule ( modules , templateUlid ) {
@@ -19,7 +23,9 @@ function findModule(modules, templateUlid) {
19
23
return module ;
20
24
}
21
25
} else {
22
- throw new Error ( "Template should implement functions: id(), config(), renderSlide(slide, run, slideDone)" ) ;
26
+ throw new Error (
27
+ "Template should implement functions: id(), config(), renderSlide(slide, run, slideDone)" ,
28
+ ) ;
23
29
}
24
30
}
25
31
@@ -31,8 +37,10 @@ function getTemplateModule(templateUlid) {
31
37
return null ;
32
38
}
33
39
34
- const module = findModule ( templateModules , templateUlid ) ??
35
- findModule ( customTemplatesModules , templateUlid ) ?? null ;
40
+ const module =
41
+ findModule ( templateModules , templateUlid ) ??
42
+ findModule ( customTemplatesModules , templateUlid ) ??
43
+ null ;
36
44
37
45
if ( module === null ) {
38
46
throw new Error ( `Cannot find module '${ templateUlid } '` ) ;
@@ -64,13 +72,10 @@ function renderSlide(slide, run, slideDone) {
64
72
const module = getTemplateModule ( templateUlid ) ;
65
73
66
74
if ( ! module ) {
67
- return '' ;
75
+ return "" ;
68
76
}
69
77
70
78
return module . renderSlide ( slide , run , slideDone ) ;
71
79
}
72
80
73
- export {
74
- getConfig ,
75
- renderSlide
76
- }
81
+ export { getConfig , renderSlide } ;
0 commit comments