Преглед изворни кода

Suppression du préfixe 0 des numéros de pages

Benoît Hubert пре 7 година
родитељ
комит
6f6b706931
1 измењених фајлова са 5 додато и 1 уклоњено
  1. 5 1
      react-tuto/gulpfile.js

+ 5 - 1
react-tuto/gulpfile.js

@@ -84,7 +84,11 @@ function extractMarkdown() {
           (carry, f) => fs.readFileAsync('src/markdown/' + dir + '/' + f)
             .then(buf => buf.toString())
             .then(content => {
-              const title = path.basename(f, '.md');
+              const basename = path.basename(f, '.md');
+              const re = /(\d+)\. (.*)/;
+              const matches = basename.match(re);
+              const title = ! matches ? basename :
+                parseInt(matches[1], 10) + '. ' + matches[2];
               return carry.concat({
                 title,
                 path: '/' + slugify(title),