@@ -5,6 +5,7 @@ const createMarkdown = require('./markdown')
5
5
const loadConfig = require ( './util/loadConfig' )
6
6
const tempPath = path . resolve ( __dirname , 'app/.temp' )
7
7
const {
8
+ encodePath,
8
9
inferTitle,
9
10
extractHeaders,
10
11
parseFrontmatter,
@@ -181,8 +182,10 @@ async function resolveOptions (sourceDir) {
181
182
// resolve pagesData
182
183
const pagesData = await Promise . all ( pageFiles . map ( async ( file ) => {
183
184
const filepath = path . resolve ( sourceDir , file )
185
+ const key = 'v-' + Math . random ( ) . toString ( 16 ) . slice ( 2 )
184
186
const data = {
185
- path : fileToPath ( file )
187
+ key,
188
+ path : encodePath ( fileToPath ( file ) )
186
189
}
187
190
188
191
if ( shouldResolveLastUpdated ) {
@@ -296,21 +299,31 @@ async function resolveComponents (sourceDir) {
296
299
}
297
300
298
301
async function genRoutesFile ( { siteData : { pages } , sourceDir, pageFiles } ) {
299
- function genRoute ( { path : pagePath } , index ) {
302
+ function genRoute ( { path : pagePath , key : componentName } , index ) {
300
303
const file = pageFiles [ index ]
301
304
const filePath = path . resolve ( sourceDir , file )
302
305
let code = `
303
306
{
307
+ name: ${ JSON . stringify ( componentName ) } ,
304
308
path: ${ JSON . stringify ( pagePath ) } ,
305
309
component: ThemeLayout,
306
310
beforeEnter: (to, from, next) => {
307
311
import(${ JSON . stringify ( filePath ) } ).then(comp => {
308
- Vue.component(${ JSON . stringify ( fileToComponentName ( file ) ) } , comp.default)
312
+ Vue.component(${ JSON . stringify ( componentName ) } , comp.default)
309
313
next()
310
314
})
311
315
}
312
316
}`
313
317
318
+ const dncodedPath = decodeURIComponent ( pagePath )
319
+ if ( dncodedPath !== pagePath ) {
320
+ code += `,
321
+ {
322
+ path: ${ JSON . stringify ( dncodedPath ) } ,
323
+ redirect: ${ JSON . stringify ( pagePath ) }
324
+ }`
325
+ }
326
+
314
327
if ( / \/ $ / . test ( pagePath ) ) {
315
328
code += `,
316
329
{
0 commit comments