Explorar o código

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

Benoît Hubert %!s(int64=7) %!d(string=hai) anos
pai
achega
6f6b706931
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  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),