Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

有关当下版本启用post_asset_folder后与abbrlink插件冲突解决方案 #68

Open
syunaht opened this issue Jan 7, 2023 · 2 comments

Comments

@syunaht
Copy link

syunaht commented Jan 7, 2023

之前有几个issues已经提到该问题,但由于hexo更新,hexo-asset-image插件集成到hexo-renderer-marked

粗略的看了下代码,确实与abbrlink插件无关。于是硬着头皮研究了好久,现附解决方案。

node_modules\hexo\lib\models\post_asset.js目录中

改动1:

return join(post.path.replace(/\.html?$/, ''), this.slug);

改为:

return join(dirname(post.path), post.slug, this.slug);

改动2:

const { join} = require('path');

改为

const { join, dirname } = require('path');

本想写个Scripts优雅地解决,尝试了很久都无法实现,只能改hexo的代码。希望后来者有人能研究出来。

@ohroy
Copy link
Owner

ohroy commented Jan 7, 2023

这个问题由hex-asset-image 应该早就解决了才是
xcodebuild/hexo-asset-image#58
不知道为啥继任者又出这个问题 😢

@AlexANSO
Copy link

之前有几个issues已经提到该问题,但由于hexo更新,hexo-asset-image插件集成到hexo-renderer-marked

粗略的看了下代码,确实与abbrlink插件无关。于是硬着头皮研究了好久,现附解决方案。

node_modules\hexo\lib\models\post_asset.js目录中

改动1:

return join(post.path.replace(/\.html?$/, ''), this.slug);

改为:

return join(dirname(post.path), post.slug, this.slug);

改动2:

const { join} = require('path');

改为

const { join, dirname } = require('path');

本想写个Scripts优雅地解决,尝试了很久都无法实现,只能改hexo的代码。希望后来者有人能研究出来。

请问大佬现在这个版本的文件是这样的如何改动?
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const warehouse_1 = __importDefault(require("warehouse"));
const path_1 = require("path");
module.exports = (ctx) => {
const PostAsset = new warehouse_1.default.Schema({
_id: { type: String, required: true },
slug: { type: String, required: true },
modified: { type: Boolean, default: true },
post: { type: warehouse_1.default.Schema.Types.CUID, ref: 'Post' },
renderable: { type: Boolean, default: true }
});
PostAsset.virtual('path').get(function () {
const Post = ctx.model('Post');
const post = Post.findById(this.post);
if (!post)
return;
// PostAsset.path is file path relative to public_dir
// no need to urlescape, #1562
// strip /.html?$/ extensions on permalink, #2134
return (0, path_1.join)(post.path.replace(/.html?$/, ''), this.slug);
});
PostAsset.virtual('source').get(function () {
return (0, path_1.join)(ctx.base_dir, this._id);
});
return PostAsset;
};
//# sourceMappingURL=post_asset.js.map

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants