Skip to content

Commit

Permalink
change trigger logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jankiny committed Aug 26, 2024
1 parent f9d9eb8 commit fbb02df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@ const config = hexo.config.hexo_ai_abstract;

hexo.extend.filter.register('after_post_render', async function (data) {

if (config.default_enable) data.aiabstract = data.aiabstract || true;
if (!data.aiabstract || data.excerpt || data.description) return data;
if (!config.enable) return data;

if (config.test) {
// 如果test模式启用,则仅当 data.aiabstract 为 true 时才生成摘要
if (!data.aiabstract || data.excerpt || data.description) return data;
} else {
// 如果 test 模式未启用,则对所有 data.excerpt 为空的文章生成摘要
if (!data.aiabstract && (data.excerpt || data.description)) return data;
}

const content = strip(data.content, config.ignoreEl);

if (content.length > config.maxTokens) {
log.info(`文章 ${data.title} 超过 maxTokens 限制`);
return data;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hexo-ai-abstract",
"version": "1.0.0",
"version": "1.0.1",
"description": "A Hexo plugin to generate AI-based abstracts for your blog posts. Fix hexo-ai-excerpt.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit fbb02df

Please sign in to comment.