使用yuque-hexo插件问题

问题描述


同步之后的标签
tags: travis,hexo
categories: hexo,travis
少了[ ]

解决方案

  • fork项目到自己github下
  • 修改项目下的package.json

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    #取消原来的插件
    "devDependencies": {
    "yuque-hexo": "^1.6.0"
    }
    #通过npm下载在自己修改的模块
    "scripts": {
    "yuque": "npm install https://github.com/Zricky/yuque-hexo/tarball/master",
    "sync": "yuque-hexo sync",
    "clean:yuque": "yuque-hexo clean",
    "dg": "npm run sync && hexo clean && hexo g -d",
    "deploy": "npm run yuque && npm run clean:yuque && npm run sync && hexo clean && hexo g ",
    "dev": "hexo clean && hexo server"
    }
  • 修改模块下adapter/hexo.js文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// 文章模板 修复标签和分类解析 
//update : 20190523
const template = `
---
<% for (const key in props) {%>
<% if (key=='categories'||key=='tags'){%>
<%= key %>: [<%= props[key] %>]
<% } else {%>
<%= key %>: <%= props[key] %>
<% } %>
<% } %>
---
<%- raw %>
`;

发现tags又可以正确解析 emmmm 条件判断中去掉tags即可

0%