From 845b38fbbf5f34988caea71bd917c473ee4248ff Mon Sep 17 00:00:00 2001 From: dimaslanjaka Date: Tue, 2 May 2023 12:46:07 +0700 Subject: [PATCH] chore: update from hexojs/hexo/pull/5153 PR https://github.com/hexojs/hexo/pull/5153 Commit https://github.com/hexojs/hexo/commit/8b95bbc722e5c77a7e8125441ed64d2ea3524ac0 --- lib/models/post_asset.ts | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/models/post_asset.ts b/lib/models/post_asset.ts index 8572029b8c..f870714785 100644 --- a/lib/models/post_asset.ts +++ b/lib/models/post_asset.ts @@ -1,14 +1,13 @@ import warehouse from 'warehouse'; -import { join, posix } from 'path'; -import type Hexo from '../hexo'; +import { dirname, join } from 'path'; -export = (ctx: Hexo) => { +export = (ctx: import('../hexo')) => { const PostAsset = new warehouse.Schema({ - _id: {type: String, required: true}, - slug: {type: String, required: true}, - modified: {type: Boolean, default: true}, - post: {type: warehouse.Schema.Types.CUID, ref: 'Post'}, - renderable: {type: Boolean, default: true} + _id: { type: String, required: true }, + slug: { type: String, required: true }, + modified: { type: Boolean, default: true }, + post: { type: warehouse.Schema.Types.CUID, ref: 'Post' }, + renderable: { type: Boolean, default: true } }); PostAsset.virtual('path').get(function() { @@ -18,9 +17,8 @@ export = (ctx: Hexo) => { // PostAsset.path is file path relative to `public_dir` // no need to urlescape, #1562 - // strip /\.html?$/ extensions on permalink, #2134 - // Use path.posix.join to avoid path.join introducing unwanted backslashes on Windows. - return posix.join(post.path.replace(/\.html?$/, ''), this.slug); + // strip extensions better on permalink, #2134 + return join(dirname(post.path), post.slug, this.slug); }); PostAsset.virtual('source').get(function() {