File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "name" : " @dxdeveloperexperience/codelab-generator" ,
3- "version" : " 1.0.7 " ,
3+ "version" : " 1.0.9 " ,
44 "description" : " " ,
55 "main" : " src/index.js" ,
66 "dependencies" : {
Original file line number Diff line number Diff line change @@ -12,7 +12,11 @@ module.exports = function(body, config) {
1212 const sections = dom . window . document . querySelectorAll ( ".sect1" ) ;
1313
1414 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 ;
1620 const body = sections [ i ] . querySelector ( ".sectionbody" ) . innerHTML ;
1721 steps . push ( `
1822 <google-codelab-step label="${ title } " duration="0">
@@ -21,9 +25,14 @@ module.exports = function(body, config) {
2125 ` ) ;
2226 }
2327
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+
2433 return ( data = {
2534 ...config ,
2635 content : steps . join ( "\n" ) ,
27- title : dom . window . document . querySelector ( "h1" ) . innerHTML
36+ title : mainTitle . innerHTML
2837 } ) ;
2938} ;
You can’t perform that action at this time.
0 commit comments