浏览代码

"lang" attribute of the HTML tag dynamic

Gabriele Lauricella 6 年之前
父节点
当前提交
addecbd7da
共有 2 个文件被更改,包括 8 次插入3 次删除
  1. 1 1
      assets/template.ejs
  2. 7 2
      bin/generator.js

+ 1 - 1
assets/template.ejs

@@ -1,5 +1,5 @@
 <!DOCTYPE html>
-<html lang="en">
+<html lang="<%= lang %>">
 <head>
     <!-- Simple HttpErrorPages | MIT License | https://github.com/HttpErrorPages -->
     <meta charset="utf-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /><meta name="viewport" content="width=device-width, initial-scale=1" />

+ 7 - 2
bin/generator.js

@@ -26,9 +26,11 @@ async function generator(configFilename, pageDefinitionFile, distPath){
     // load css
     const css = await _fs.readFile(cssPath, 'utf8');
 
+    const lang = pageDefinitionFile.substr(-10, 2);
+
     console.log('Create/Empty distribution folder: "'+distPath+'"\n');
 
-    if(_fs.exists(distPath)) {
+    if(await _fs.exists(distPath)) {
         await _fs.rmrf(distPath);
     }
     await _fs.mkdirp(distPath);
@@ -43,9 +45,12 @@ async function generator(configFilename, pageDefinitionFile, distPath){
         // inject errorcode
         pconf.code = p;
 
-        // inject foote
+        // inject footer
         pconf.footer = pconf.footer || config.footer;
 
+        // inject footer
+        pconf.lang = lang || 'en';
+
         // render page
         const content = await _pageRenderer(tpl, css, pconf);