1 Star 0 Fork 0

米豆/hexo-ncm-widget

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.js 1.14 KB
一键复制 编辑 原始数据 按行查看 历史
MiMonarchRD 提交于 2021-09-23 12:16 . v1.0.0 ncm hexo插件
const { AsyncGetData, readJson, writeJson } = require('./lib/handler');
const path = require('path');
const fs = require('hexo-fs')
const js = hexo.extend.helper.get('js').bind(hexo);
writeJson();
AsyncGetData(hexo.config.ncm_widget.playlist_id);
// hexo.extend.helper.register('ncmWidget', async () => {
// return ncmwidget();
// }, {async: true});
hexo.render.render({path: path.resolve(__dirname, './layout/ncm-widget.ejs')}, {data: readJson(), config: hexo.config.ncm_widget}).then((res) => {
hexo.extend.helper.register('ncmWidget', () => res);
})
hexo.render.render({path: path.resolve(__dirname, './source/ncm-widget.styl'), engine: 'styl'}).then((res) => {
hexo.extend.injector.register('head_end', () => "<style>"+res+"</style>");
})
hexo.extend.injector.register('body_end', () => js('lib/ncm/ncm.js'));
hexo.extend.filter.register('before_generate', function(){
hexo.extend.generator.register('ncm_asset', ()=>[
{
path: 'lib/ncm/ncm.js',
data: function(){
return fs.createReadStream(
path.resolve(path.resolve(__dirname, "./lib"),"ncm.js"))
}
}
]);
})
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/mimonarchrd/hexo-ncm-widget.git
git@gitee.com:mimonarchrd/hexo-ncm-widget.git
mimonarchrd
hexo-ncm-widget
hexo-ncm-widget
main

搜索帮助