11import warehouse from 'warehouse' ;
2- import { join , dirname } from 'path' ;
2+ import { join , posix } from 'path' ;
33import type Hexo from '../hexo' ;
44
55export = ( ctx : Hexo ) => {
66 const PostAsset = new warehouse . Schema ( {
7- _id : { type : String , required : true } ,
8- slug : { type : String , required : true } ,
9- modified : { type : Boolean , default : true } ,
10- post : { type : warehouse . Schema . Types . CUID , ref : 'Post' } ,
11- renderable : { type : Boolean , default : true }
7+ _id : { type : String , required : true } ,
8+ slug : { type : String , required : true } ,
9+ modified : { type : Boolean , default : true } ,
10+ post : { type : warehouse . Schema . Types . CUID , ref : 'Post' } ,
11+ renderable : { type : Boolean , default : true }
1212 } ) ;
1313
1414 PostAsset . virtual ( 'path' ) . get ( function ( ) {
@@ -18,8 +18,9 @@ export = (ctx: Hexo) => {
1818
1919 // PostAsset.path is file path relative to `public_dir`
2020 // no need to urlescape, #1562
21- // strip extensions better on permalink, #2134
22- return join ( dirname ( post . path ) , post . slug , this . slug ) ;
21+ // strip /\.html?$/ extensions on permalink, #2134
22+ // Use path.posix.join to avoid path.join introducing unwanted backslashes on Windows.
23+ return posix . join ( post . path . replace ( / \. h t m l ? $ / , '' ) , this . slug ) ;
2324 } ) ;
2425
2526 PostAsset . virtual ( 'source' ) . get ( function ( ) {
0 commit comments