mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
nuxt-generate
This commit is contained in:
parent
b9680bc3ea
commit
a8776de913
3
.gitignore
vendored
3
.gitignore
vendored
@ -7,3 +7,6 @@ npm-debug.log
|
||||
|
||||
# other
|
||||
.nuxt
|
||||
|
||||
# dist example generation
|
||||
examples/**/dist
|
||||
|
@ -5,7 +5,7 @@ const co = require('co')
|
||||
const pify = require('pify')
|
||||
const debug = require('debug')('nuxt:generate')
|
||||
const _ = require('lodash')
|
||||
const { resolve, join } = require('path')
|
||||
const { resolve, join, dirname } = require('path')
|
||||
const copy = pify(fs.copy)
|
||||
const remove = pify(fs.remove)
|
||||
const writeFile = pify(fs.writeFile)
|
||||
@ -24,7 +24,7 @@ module.exports = function () {
|
||||
var srcBuiltPath = resolve(this.dir, '.nuxt', 'dist')
|
||||
var distPath = resolve(this.dir, this.options.generate.dir)
|
||||
var distNuxtPath = resolve(distPath, '_nuxt')
|
||||
co(function * () {
|
||||
return co(function * () {
|
||||
/*
|
||||
** Clean destination folder
|
||||
*/
|
||||
@ -46,16 +46,16 @@ module.exports = function () {
|
||||
** Generate html files from routes
|
||||
*/
|
||||
var promises = []
|
||||
this.options.routes.forEach((route) => {
|
||||
this.routes.forEach((route) => {
|
||||
var promise = this.renderRoute(route.path)
|
||||
.then(({ html }) => {
|
||||
var path = route.path
|
||||
path += path[path.length - 1] === '/' ? 'index.html' : '.html'
|
||||
debug('Generate file : ' + path)
|
||||
var path = join(route.path, '/', 'index.html') // /about -> /about/index.html
|
||||
debug('Generate file: ' + path)
|
||||
path = join(distPath, path)
|
||||
// Make sure the sub folders are created
|
||||
fs.mkdirsSync(dirname(path))
|
||||
return writeFile(path, html, 'utf8')
|
||||
})
|
||||
console.log(promise)
|
||||
promises.push(promise)
|
||||
})
|
||||
return Promise.all(promises)
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nuxt",
|
||||
"version": "0.3.1",
|
||||
"version": "0.3.2",
|
||||
"description": "A minimalistic framework for server-rendered Vue.js applications (inspired by Next.js)",
|
||||
"main": "index.js",
|
||||
"license": "MIT",
|
||||
|
Loading…
Reference in New Issue
Block a user