1
0
Просмотр исходного кода

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

Benoît Hubert 7 лет назад
Родитель
Сommit
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),