11import warehouse from 'warehouse' ;
2- import { join } from 'path' ;
2+ import { dirname , join } from 'path' ;
33
4- export = ctx => {
4+ export = ( ctx : import ( '../hexo' ) ) => {
55 const PostAsset = new warehouse . Schema ( {
6- _id : { type : String , required : true } ,
7- slug : { type : String , required : true } ,
8- modified : { type : Boolean , default : true } ,
9- post : { type : warehouse . Schema . Types . CUID , ref : 'Post' } ,
10- renderable : { type : Boolean , default : true }
6+ _id : { type : String , required : true } ,
7+ slug : { type : String , required : true } ,
8+ modified : { type : Boolean , default : true } ,
9+ post : { type : warehouse . Schema . Types . CUID , ref : 'Post' } ,
10+ renderable : { type : Boolean , default : true }
1111 } ) ;
1212
1313 PostAsset . virtual ( 'path' ) . get ( function ( ) {
@@ -17,8 +17,8 @@ export = ctx => {
1717
1818 // PostAsset.path is file path relative to `public_dir`
1919 // no need to urlescape, #1562
20- // strip /\.html?$/ extensions on permalink, #2134
21- return join ( post . path . replace ( / \. h t m l ? $ / , '' ) , this . slug ) ;
20+ // strip extensions better on permalink, #2134
21+ return join ( dirname ( post . path ) , post . slug , this . slug ) ;
2222 } ) ;
2323
2424 PostAsset . virtual ( 'source' ) . get ( function ( ) {
0 commit comments