|
|
@@ -119,16 +119,16 @@ app.post('/:repoSlug/examples', function(req, res) {
|
|
|
// Prepare files to write
|
|
|
var targetDir = __dirname + '/exemples/' + repoSlug + '/' + exampleSlug;
|
|
|
var files = mapObjToArray({
|
|
|
- 'contenu.html': '',
|
|
|
- 'script.js': '',
|
|
|
+ 'contenu.html': '<!-- ' + title + '-->\n',
|
|
|
+ 'script.js': '// ' + title,
|
|
|
'config.json': beautify(config, null, 2, 100)
|
|
|
}, 'file', 'content');
|
|
|
fs.mkdirAsync(targetDir)
|
|
|
.then(() => Promise.map(
|
|
|
files, ({ file, content }) => fs.writeFileAsync(targetDir + '/' + file, content)
|
|
|
))
|
|
|
- .then(files => repo.examples.push({ slug: slug, title: title }))
|
|
|
- .then(() => res.json({ slug: exampleSlug, title: title }));
|
|
|
+ .then(files => repo.examples.push(config))
|
|
|
+ .then(() => res.json(config));
|
|
|
});
|
|
|
|
|
|
app.get('/examples/:slug', function(req, res) {
|