Coder Social home page Coder Social logo

xu-song / hexo-auto-category Goto Github PK

View Code? Open in Web Editor NEW
94.0 4.0 9.0 41 KB

Generate categories automatically for each post in Hexo

Home Page: https://blog.eson.org/pub/e2f6e239/

License: MIT License

JavaScript 100.00%
hexo hexo-plugin category node-module folder-structure directory-tree

hexo-auto-category's Issues

建议加个minDepth参数

var minDepth = this.config.auto_category.minDepth || 0;

...

tmpPost.categories = categories.slice(1+Math.min(minDepth, categories.length-2), 1+Math.min(depth, categories.length-2));

关于categories为空的问题

您好,按照您提供的设置方案,最后在hexo g时有所有categories被替换为[]的情况:
Weixin Screenshot_20240318174750
不论如何编辑front-matter,categories也都将被替换为categories: []。我对hexo了解不多,请问您有什么看法吗?

以下是版本信息。

hexo: 7.1.1
hexo-cli: 4.3.1
os: win32 10.0.22631
node: 20.9.0
acorn: 8.10.0
ada: 2.6.0
ares: 1.19.1
base64: 0.5.0
brotli: 1.0.9
cjs_module_lexer: 1.2.2
cldr: 43.1
icu: 73.2
llhttp: 8.1.1
modules: 115
napi: 9
nghttp2: 1.57.0
nghttp3: 0.7.0
ngtcp2: 0.8.1
openssl: 3.0.10+quic
simdutf: 3.2.17
tz: 2023c
undici: 5.26.3
unicode: 15.0
uv: 1.46.0
uvwasi: 0.0.18
v8: 11.3.244.8-node.16
zlib: 1.2.13.1-motley

这个问题请看一下,装了这个hexo-auto-category插件,clean了之后 hexo g的时候就会报错,卸载这个插件之后就没事

这个问题请看一下,装了这个hexo-auto-category插件,clean了之后 hexo g的时候就会报错,卸载这个插件之后就没事

FATAL {
err: TypeError: Cannot read property 'enable' of undefined
at Hexo.logic (D:\hexo\node_modules\hexo-auto-category\lib\logic.js:16:35)
at Hexo.tryCatcher (D:\hexo\node_modules\bluebird\js\release\util.js:16:23)
at Hexo. (D:\hexo\node_modules\bluebird\js\release\method.js:15:34)
at D:\hexo\node_modules\hexo\lib\extend\filter.js:67:52
at tryCatcher (D:\hexo\node_modules\bluebird\js\release\util.js:16:23)
at Object.gotValue (D:\hexo\node_modules\bluebird\js\release\reduce.js:166:18)
at Object.gotAccum (D:\hexo\node_modules\bluebird\js\release\reduce.js:155:25)
at Object.tryCatcher (D:\hexo\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler (D:\hexo\node_modules\bluebird\js\release\promise.js:547:31)
at Promise._settlePromise (D:\hexo\node_modules\bluebird\js\release\promise.js:604:18)
at Promise._settlePromise0 (D:\hexo\node_modules\bluebird\js\release\promise.js:649:10)
at Promise._settlePromises (D:\hexo\node_modules\bluebird\js\release\promise.js:729:18)
at _drainQueueStep (D:\hexo\node_modules\bluebird\js\release\async.js:93:12)
at _drainQueue (D:\hexo\node_modules\bluebird\js\release\async.js:86:9)
at Async._drainQueues (D:\hexo\node_modules\bluebird\js\release\async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (D:\hexo\node_modules\bluebird\js\release\async.js:15:14)
at processImmediate (node:internal/timers:462:21)
} Something's wrong. Maybe you can find the solution here: %s https://hexo.io/docs/troubleshooting.html

通过Github Action自动部署时没有起作用

我在本地测试可以成功分类
但是通过Github Action自动部署时,却发现没有起作用。
通过log查看,已经运行改代码

INFO  Generated: categories [life] for post [hello_world.md]

但是在输出文件中,没有category文件夹。
如果手动添加category则可以产生category文件夹。

Github action log for your refer:
https://github.com/liunaijie/liunaijie.github.io/actions/runs/6027436406/job/16352635372

click hexo deploy to see the detail.

这真是一个很好👍插件,有问题请教下,不甚感激!

这不是issue,由于此问题我亟待解决,所以我在这里请教下各位。
如果长时间没人回答,我会关掉此问题。

  • 问题1
    hexo new --path go/hello world "hello world" 将会在 source/_posts/go/ 目录下生成 hello world.md文件,并且标题为”hello world”。但是我想省略命令中的"hello world”, 让文件名自动生成标题该如何写呢?

  • 问题2
    hexo new --path go/hello world "hello world" 如分类层级较多,比如 编程语言/后端/go,每次在go下创建md文件都要写全路径,这种方式比较影响效率,有没有像cd目录名称带提示的方法呢?

报错TypeError: tmpPost.categories.join is not a function

hexo g 时报错,卸载掉hexo-auto-category 就没事儿,所以应该还是它的问题,想问问该怎么办?
FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html TypeError: tmpPost.categories.join is not a function at Hexo.logic (D:\hexo\blog\node_modules\hexo-auto-category\lib\logic.js:33:55) at Hexo.tryCatcher (D:\hexo\blog\node_modules\bluebird\js\release\util.js:16:23) at Hexo.<anonymous> (D:\hexo\blog\node_modules\bluebird\js\release\method.js:15:34) at Promise.each.filter (D:\hexo\blog\node_modules\hexo\lib\extend\filter.js:60:50) at tryCatcher (D:\hexo\blog\node_modules\bluebird\js\release\util.js:16:23) at Object.gotValue (D:\hexo\blog\node_modules\bluebird\js\release\reduce.js:155:18) at Object.gotAccum (D:\hexo\blog\node_modules\bluebird\js\release\reduce.js:144:25) at Object.tryCatcher (D:\hexo\blog\node_modules\bluebird\js\release\util.js:16:23) at Promise._settlePromiseFromHandler (D:\hexo\blog\node_modules\bluebird\js\release\promise.js:517:31) at Promise._settlePromise (D:\hexo\blog\node_modules\bluebird\js\release\promise.js:574:18) at Promise._settlePromise0 (D:\hexo\blog\node_modules\bluebird\js\release\promise.js:619:10) at Promise._settlePromises (D:\hexo\blog\node_modules\bluebird\js\release\promise.js:699:18) at _drainQueueStep (D:\hexo\blog\node_modules\bluebird\js\release\async.js:138:12) at _drainQueue (D:\hexo\blog\node_modules\bluebird\js\release\async.js:131:9) at Async._drainQueues (D:\hexo\blog\node_modules\bluebird\js\release\async.js:147:5) at Immediate.Async.drainQueues [as _onImmediate] (D:\hexo\blog\node_modules\bluebird\js\release\async.js:17:14) at runCallback (timers.js:705:18) at tryOnImmediate (timers.js:676:5) at processImmediate (timers.js:658:5)

上面一个问题类似,hexo s 后重复打印

INFO  Generated: categories [] for post [test]
INFO  Generated: categories [] for post [Hello World]
INFO  Generated: categories [] for post [test]
INFO  Generated: categories [] for post [Hello World]
INFO  Generated: categories [] for post [test]
INFO  Generated: categories [] for post [Hello World]
INFO  Generated: categories [] for post [test]
INFO  Generated: categories [] for post [Hello World]

hexo g 成功,无重复打印
hexo s 重复打印上述内容,但 http://localhost:4000/ 可以访问预览

seeking advice

TODO

  • debug mode
    • more log. log.debug()
    • enable clear category
  • cn doc
  • cli mode, like hexo init/ hexo s
    • hexo category
    • hexo category --debug

status header

[![Build Status](https://travis-ci.org/hexojs/hexo-server.svg?branch=master)](https://travis-ci.org/hexojs/hexo-server)
[![NPM version](https://badge.fury.io/js/hexo-server.svg)](http://badge.fury.io/js/hexo-server) 
[![Coverage Status](https://img.shields.io/coveralls/hexojs/hexo-server.svg)](https://coveralls.io/r/hexojs/hexo-server?branch=master)
[![Build status](https://ci.appveyor.com/api/projects/status/ycbw8t7w3kjju0tv/branch/master?svg=true)](https://ci.appveyor.com/project/tommy351/hexo-server/branch/master)

_Post.md 可以指定生成分类目录需要几层吗?

_Post.md 可以指定生成分类目录需要几层吗?

在站点配置文件配置后,的确作用了_post的目录,不过我想在站点配置文件配置的是目录层级为2的情况下.想某些目录不需要过深的层级显示,比如我只想显示python-nomrmal这一层就截止,不要把下级目录生成出来,
image

我手动在index.md定义这个属性,测试无效,true false 都试过
image

@xu-song

在应用该插件的工程中遇到了tmppPost.categories不是个函数这个问题。

INFO Generated: categories [[]] for post [高数文档.md]
INFO Generated: categories [[]] for post [考研计划:备考大纲-转载.md]
FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
TypeError: tmpPost.categories.join is not a function
at Hexo.logic (C:\Users\Administrator\WebstormProjects\blog\node_modules\hexo-auto-category\lib\logic.js:33:55)
at Hexo.tryCatcher (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird\js\release\util.js:16:23)
at Hexo. (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird\js\release\method.js:15:34)
at C:\Users\Administrator\WebstormProjects\blog\node_modules\hexo\lib\extend\filter.js:61:50
at tryCatcher (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird\js\release\util.js:16:23)
at Object.gotValue (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird\js\release\reduce.js:166:18)
at Object.gotAccum (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird\js\release\reduce.js:155:25)
at Object.tryCatcher (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird\js\release
promise.js:547:31)
at Promise._settlePromise (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird\js\release\promise.js:
604:18)
at Promise._settlePromise0 (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird\js\release\promise.js
:649:10)
at Promise._settlePromises (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird\js\release\promise.js
:729:18)
at _drainQueueStep (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird\js\release\async.js:93:12)
at _drainQueue (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird\js\release\async.js:86:9)
at Async._drainQueues (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird\js\release\async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird
\js\release\async.js:15:14)
INFO Start processing
FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
TypeError: tmpPost.categories.join is not a function
at Hexo.logic (C:\Users\Administrator\WebstormProjects\blog\node_modules\hexo-auto-category\lib\logic.js:33:55)
at Hexo.tryCatcher (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird\js\release\util.js:16:23)
at Hexo. (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird\js\release\method.js:15:34)
at C:\Users\Administrator\WebstormProjects\blog\node_modules\hexo\lib\extend\filter.js:61:50
at tryCatcher (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird\js\release\util.js:16:23)
at Object.gotValue (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird\js\release\reduce.js:166:18)
at Object.gotAccum (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird\js\release\reduce.js:155:25)
at Object.tryCatcher (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird\js\release
promise.js:547:31)
at Promise._settlePromise (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird\js\release\promise.js:
604:18)
at Promise._settlePromise0 (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird\js\release\promise.js
:649:10)
at Promise._settlePromises (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird\js\release\promise.js
:729:18)
at _drainQueueStep (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird\js\release\async.js:93:12)
at _drainQueue (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird\js\release\async.js:86:9)
at Async._drainQueues (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird\js\release\async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\Administrator\WebstormProjects\blog\node_modules\bluebird
\js\release\async.js:15:14)

插件会将_draft下的目录生成分类

_draft下的目录也生成了分类,使用hexo s预览时,或是部署到github page上,都将_draft下的目录生成分类。
附:我使用的是0.1.5的最新版本。

join is not a function

运行hexo g的时候提示tmpPost.categories.join is not a function,以下是输出,不懂js不会修,求助。

➜ BlogCollections hexo g && hexo s
INFO Validating config
INFO Start processing
FATAL {
err: TypeError: tmpPost.categories.join is not a function
at Hexo.logic (/Users/simon/Documents/BlogCollections/node_modules/hexo-auto-category/lib/logic.js:33:55)
at Hexo.tryCatcher (/Users/simon/Documents/BlogCollections/node_modules/bluebird/js/release/util.js:16:23)
at Hexo. (/Users/simon/Documents/BlogCollections/node_modules/bluebird/js/release/method.js:15:34)
at /Users/simon/Documents/BlogCollections/node_modules/hexo/lib/extend/filter.js:67:52
at tryCatcher (/Users/simon/Documents/BlogCollections/node_modules/bluebird/js/release/util.js:16:23)
at Object.gotValue (/Users/simon/Documents/BlogCollections/node_modules/bluebird/js/release/reduce.js:166:18)
at Object.gotAccum (/Users/simon/Documents/BlogCollections/node_modules/bluebird/js/release/reduce.js:155:25)
at Object.tryCatcher (/Users/simon/Documents/BlogCollections/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/simon/Documents/BlogCollections/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/Users/simon/Documents/BlogCollections/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/Users/simon/Documents/BlogCollections/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/Users/simon/Documents/BlogCollections/node_modules/bluebird/js/release/promise.js:729:18)
at _drainQueueStep (/Users/simon/Documents/BlogCollections/node_modules/bluebird/js/release/async.js:93:12)
at _drainQueue (/Users/simon/Documents/BlogCollections/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/Users/simon/Documents/BlogCollections/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (/Users/simon/Documents/BlogCollections/node_modules/bluebird/js/release/async.js:15:14)
at processImmediate (internal/timers.js:461:21)
} Something's wrong. Maybe you can find the solution here: %s https://hexo.io/docs/troubleshooting.html

文件夹更名后文章内容被清空

例如,当进行以下操作时,文件夹下所有的文章内容会被清空:

  1. _posts目录下存在一个文件夹,如:test11。文件夹下有文章test.md
  2. hexo三连:hexo clean && hexo g && hexo s
    image
  3. 此时更改文件夹的名字:test 11 22。热更新后,重命名后的文件夹下所有的文章内容均被清空。
    image

日志:

INFO  Generated: categories [[ 'test 11 22' ]] for post [test.md]
WARN  Trying to "create" _posts/test 11 22/test.md, but the file already exists!
INFO  No title found for post [source/_posts/test 11 22/test.md][  ]
INFO  Generate link [0] for post [source/_posts/test 11 22/test.md][  ]
INFO  Generated: categories [undefined] for post [source/_posts/test 11 22/test.md][  ]
INFO  Generated: categories [[ 'test 11 22' ]] for post [test.md]
INFO  No title found for post [source/_posts/test 11 22/test.md][  ]
INFO  Generate link [0] for post [source/_posts/test 11 22/test.md][  ]
INFO  Generated: categories [[ 'test 11 22' ]] for post [source/_posts/test 11 22/test.md][  ]

不知道是不是和文件名空格有关,尝试复现这个问题的时候只在某些情况下复现成功。最初发现这个 Bug 是 hexo s 执行后,我把名为 out of date 的文件夹,改为 OutOfDate 之后,OutOfDate 下的所有文章被清空。

警告:这个插件会直接修改源文件

试用了一下,发现这个插件直接把所有文档的页头全部改了一遍。
包括date的格式、tags与categories的格式以及顺序,相当于整体格式化。
如果你是强迫症的话,这种格式化会非常烦人,我试用之前忘记备份原始文件,只好可怜的一个个再改回来。。。

可以使用hexo-directory-category这个插件,它没有直接修改源文件。

请作者增加一个警告,告诉其他人,你的插件会修改MarkDown源文件,其中的风险起码应该告知用户。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.