感謝 Uncle_drew 製作出Hexo隨機文章功能插件 hexo-generator-random
這邊記錄一下安裝過程。
1. 安裝 object-assign
npm install object-assign
|
2. 下載並添加 hexo-generator-random
下載 hexo-generator-random 倉庫的內容,然後把它放進 ../blog/node_modules
文件夾中。
3. 修改 package.json
在 ../blog/package.json
這個檔案中,添加以下:
"object-assign": "^4.1.1", "hexo-generator-random": "^1.0.0"
|
以下是我 package.json
檔案中的完整內容,給參考。
{ "name": "hexo-site", "version": "0.0.0", "private": true, "scripts": { "build": "hexo generate", "clean": "hexo clean", "deploy": "hexo deploy", "server": "hexo server" }, "hexo": { "version": "4.2.0" }, "dependencies": { "cheerio": "^0.22.0", "hexo": "^4.0.0", "hexo-blog-encrypt": "^3.0.12", "hexo-deployer-git": "^2.1.0", "hexo-generator-archive": "^1.0.0", "hexo-generator-calendar": "git://github.com/howiefh/hexo-generator-calendar.git", "hexo-generator-category": "^1.0.0", "hexo-generator-feed": "^2.2.0", "hexo-generator-index": "^1.0.0", "hexo-generator-search": "^2.4.0", "hexo-generator-tag": "^1.0.0", "hexo-hide-posts": "^0.1.0", "hexo-renderer-ejs": "^1.0.0", "hexo-renderer-jade": "^0.5.0", "hexo-renderer-marked": "^2.0.0", "hexo-renderer-pug": "^1.0.0", "hexo-renderer-stylus": "^1.1.0", "hexo-server": "^1.0.0", "hexo-wordcount": "^6.0.1", "object-assign": "^4.1.1", "hexo-generator-random": "^1.0.0" } }
|
4. 檢查
到 ../blog/public
看,會看見一個名為 random.html
的檔案已自動生成。
開啓這個 random.html
檔,隨機會到了其中一篇文章。成功。
在 ..\themes\Butterfly\_config.yml
,在 menu 添加隨機功能。
隨機: /random || fa fa-question
|
完成!
References