pubdate: 2019-03-06 20:35:28
难受的是之后配置一直不成功,明明配置的一样了,界面却不变。
解决方案是将 nico server --watch 关掉重启就行了-
=== 没有找到对应的渲染器 NodeBackslash ===
-
pubdate: 文章的发布时间。(主题编写请注意:将会被转化为 moment 对象)
tags: 文章标签。(将会被转化为 Array)
status: 文章的状态(public, secret, draft,默认为 public)
template: 文章用什么模板来渲染,post 类文章默认为 post.html - page 类文章默认为 page.html
上面内置支持的元信息,在主题编写中,可直接访问,如 {{post.pubdate}}。除了内置支持的元信息,你还可以自己扩展,比如:
这时,在主题中必须使用 {{post.meta.topic}} 才能获得该信息
今天又遇到一个问题 编译之后 staitc 目录不存在还有一些奇奇怪怪的问题,原因是我在 content 下安装了 node 模块。。。。删掉就好了
扩展 nico 让他在 pre 标签上有 language 属性
就是自动拉取 Git 的代码然后 nico build
typescript
const shell = require("shelljs");
const iconv = require("iconv-lite"); // 编码
export async function gitPull(url: string) {
try {
shell.cd(url);
let git = await exec("git pull");
let nico = await exec("nico build");
} catch (error) {
console.log(error);
}
}
//执行命令返回Promise
function exec(cmd) {
return new Promise((resolve, reject) => {
shell.exec(cmd, { encoding: "binary" }, function(err, stdout, stderr) {
if (err) reject(iconvDecode(stderr));
resolve(iconvDecode(stdout));
});
});
}
//转换编码
function iconvDecode(str = "") {
const encoding = "gb2312";
const binaryEncoding = "binary";
return iconv.decode(Buffer.from(str, binaryEncoding), encoding);
}
nico 自带的代码高亮好像只有 HTML,于是用了 highlightjs 的。要注意的是需要运行 highlightBlock 来高亮指定的元素中的代码,我将以下代码添加到了 nico 的 templates 中。_记得引入
highlightjs
_
html{run}
document.querySelectorAll("pre").forEach(function(value) {
hljs.highlightBlock(value);
});
因为文件名中含有大写字母,而 nico“贴心的”帮你转为小写了下划线
=== 没有找到对应的渲染器 NodeBackslash ===
也会被转为-
全局安装 socket.io 然后
就可以了