Skip to content

Commit

Permalink
chore: update from hexojs/pull/5153
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaslanjaka committed Oct 3, 2024
1 parent b75837b commit 845b38f
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions lib/models/post_asset.ts
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -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() {
Expand Down

0 comments on commit 845b38f

Please sign in to comment.