diff --git a/README.md b/README.md index dd64954..95f291c 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ To generate docs with only specific simulation examples, add them as an argument The generated docs load sim to gather runtime information. To bypass this step and use stored data from sim loads: - `npm run build-json` + `npm run build-html` NOTE: This will only log out the html string, not write it to the output file. The above snippet will copy the output into a file of your choosing. diff --git a/js/createHTMLString.js b/js/createHTMLString.js index cfdf1a3..13307bc 100644 --- a/js/createHTMLString.js +++ b/js/createHTMLString.js @@ -71,12 +71,6 @@ const createHTMLString = function( data ) { const simsByComponent = Object.keys( components ).map( component => { return { name: component, sims: Object.keys( components[ component ] ) }; } ); - - const baseTemplate = getHandlebarsTemplate( 'base.html' ); - const parentComponentTemplate = getHandlebarsTemplate( 'parentComponent.html' ); - const singleComponentTemplate = getHandlebarsTemplate( 'singleComponent.html' ); - const componentsBySimulationTemplate = getHandlebarsTemplate( 'componentsBySimulation.html' ); - const simsByComponentTemplate = getHandlebarsTemplate( 'simsByComponent.html' ); let contentHTML = ''; // get list of files in all docs/ directories, excluding binder (can be async) @@ -89,13 +83,42 @@ const createHTMLString = function( data ) { mdData[ name ] = processFile( docPath ); } +// handlebars helper functions + handlebars.registerHelper( 'componentLink', ( repo, component ) => { + return new handlebars.SafeString( + `Source Code and Options` + ); + } ); + + handlebars.registerHelper( 'simPageLink', simName => { + return new handlebars.SafeString( + `PhET Simulation Page` + ); + } ); + + handlebars.registerHelper( 'navList', ( components, parentRepo ) => { + let itemsHTML = components.map( c => { + const repo = mdData[ c ]?.repo || parentRepo; + return `