Skip to content

Commit 8b95bbc

Browse files
authored
fix(post-asset): strip extensions better on permalink (#5153)
* compatible with hexo-abbrlink * strip extensions better on permalink
1 parent 7edbf25 commit 8b95bbc

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/models/post_asset.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const { Schema } = require('warehouse').default;
4-
const { join } = require('path');
4+
const { join, dirname } = require('path');
55

66
module.exports = ctx => {
77
const PostAsset = new Schema({
@@ -19,8 +19,8 @@ module.exports = ctx => {
1919

2020
// PostAsset.path is file path relative to `public_dir`
2121
// no need to urlescape, #1562
22-
// strip /\.html?$/ extensions on permalink, #2134
23-
return join(post.path.replace(/\.html?$/, ''), this.slug);
22+
// strip extensions better on permalink, #2134
23+
return join(dirname(post.path), post.slug, this.slug);
2424
});
2525

2626
PostAsset.virtual('source').get(function() {

0 commit comments

Comments
 (0)