File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @dxdeveloperexperience/codelab-generator" ,
3
- "version" : " 1.0.7 " ,
3
+ "version" : " 1.0.9 " ,
4
4
"description" : " " ,
5
5
"main" : " src/index.js" ,
6
6
"dependencies" : {
Original file line number Diff line number Diff line change @@ -12,7 +12,11 @@ module.exports = function(body, config) {
12
12
const sections = dom . window . document . querySelectorAll ( ".sect1" ) ;
13
13
14
14
for ( let i = 0 ; i < sections . length ; i ++ ) {
15
- const title = sections [ i ] . querySelector ( "h2" ) . innerHTML ;
15
+ const titleElement = sections [ i ] . querySelector ( "h2" ) ;
16
+ if ( ! titleElement ) {
17
+ console . error ( "Make sure each section of your codelab have a dedicated title" ) ;
18
+ }
19
+ const title = titleElement . innerHTML ;
16
20
const body = sections [ i ] . querySelector ( ".sectionbody" ) . innerHTML ;
17
21
steps . push ( `
18
22
<google-codelab-step label="${ title } " duration="0">
@@ -21,9 +25,14 @@ module.exports = function(body, config) {
21
25
` ) ;
22
26
}
23
27
28
+ const mainTitle = dom . window . document . querySelector ( "h1" ) ;
29
+ if ( ! mainTitle ) {
30
+ console . error ( "Make sure that your codelab have a level 1 heading" ) ;
31
+ }
32
+
24
33
return ( data = {
25
34
...config ,
26
35
content : steps . join ( "\n" ) ,
27
- title : dom . window . document . querySelector ( "h1" ) . innerHTML
36
+ title : mainTitle . innerHTML
28
37
} ) ;
29
38
} ;
You can’t perform that action at this time.
0 commit comments