@@ -18,7 +18,7 @@ const BOILERPLATE_FOLDER_NAME = '_boilerplates';
1818const SITE_ASSET_FOLDER_NAME = 'asset' ;
1919const TEMPLATE_ROOT_FOLDER_NAME = 'template' ;
2020const TEMPLATE_SITE_ASSET_FOLDER_NAME = 'markbind' ;
21- const USER_VARIABLES_PATH = '_system /variables.md' ;
21+ const USER_VARIABLES_PATH = '_markbind /variables.md' ;
2222
2323const SITE_CONFIG_DEFAULT = {
2424 baseUrl : '' ,
@@ -40,6 +40,11 @@ const SITE_CONFIG_DEFAULT = {
4040
4141const INDEX_MARKDOWN_DEFAULT = '# Hello world\nWelcome to your page generated with MarkBind.\n' ;
4242
43+ const USER_VARIABLES_DEFAULT = '<span id="example">\n'
44+ + 'To inject this HTML segment in your markbind files, use {{ example }} where you want to place it.\n'
45+ + 'More generally, surround the segment\'s id with double curly braces.\n'
46+ + '</span>' ;
47+
4348function Site ( rootPath , outputPath ) {
4449 this . rootPath = rootPath ;
4550 this . outputPath = outputPath ;
@@ -86,6 +91,7 @@ Site.initSite = function (rootPath) {
8691 const boilerplatePath = path . join ( rootPath , BOILERPLATE_FOLDER_NAME ) ;
8792 const configPath = path . join ( rootPath , SITE_CONFIG_NAME ) ;
8893 const indexPath = path . join ( rootPath , INDEX_MARKDOWN_FILE ) ;
94+ const userDefinedVariablesPath = path . join ( rootPath , USER_VARIABLES_PATH ) ;
8995 // TODO: log the generate info
9096 return new Promise ( ( resolve , reject ) => {
9197 fs . accessAsync ( boilerplatePath )
@@ -109,6 +115,13 @@ Site.initSite = function (rootPath) {
109115 }
110116 return fs . outputFileAsync ( indexPath , INDEX_MARKDOWN_DEFAULT ) ;
111117 } )
118+ . then ( ( ) => fs . accessAsync ( userDefinedVariablesPath ) )
119+ . catch ( ( ) => {
120+ if ( fs . existsSync ( userDefinedVariablesPath ) ) {
121+ return Promise . resolve ( ) ;
122+ }
123+ return fs . outputFileAsync ( userDefinedVariablesPath , USER_VARIABLES_DEFAULT ) ;
124+ } )
112125 . then ( resolve )
113126 . catch ( reject ) ;
114127 } ) ;
0 commit comments