现已更新 2.0!
English README by @gwzz & @xiazeyu
为你的hexo添加色气满满的live2d吧!
示例: https://huaji8.top/post/live2d-plugin-2.0/
安装模块:
npm install --save hexo-helper-live2d
Tips: 遇到npm的相关错误,试试
npm cache verify
或npm cache clean
呗~
并将下面的代码加入主题。
通常添加在 layout/layout.ejs
或 layout/_layout.swig
中的 </body>
之前
ejs:
<%- live2d() %>
swig (next主题):
{{ live2d() }}
有2种方法
在 hexo 的 _config.yml
中添加参数:
live2d:
model: nipsilon
在 hexo 主题 的 _config.yml
中添加参数:
live2d:
model: nipsilon
第二种配置会覆盖第一种
# Live2D
## https://github.com/EYHN/hexo-helper-live2d
live2d:
model: z16 # 模型名称 默认值: z16
width: 150 # 宽度 默认值: 150
height: 300 # 高度 默认值: 300
opacity: 0..9 # 透明度 默认值: 0.9
mobileShow: true # 是否在移动设备上显示 默认值: true
mobileWidth: 75 # 移动设备上的宽度 默认值: 75
mobileHeight: 150 # 移动设备上的高度 默认值: 150
mobileOpacity: 0.8 # 移动设备上的透明度 默认值: 0.8
position: right # 模型左右侧放置位置 默认值: right
horizontalOffset: 0 # 元素的水平偏移 默认值: 0
verticalOffset: -20 # 元素的底部偏移 默认值: -20
className: live2d # 元素的类名 默认值: live2d
id: live2dcanvas # 元素的id 默认值: live2dcanvas
-
model
: 模型名称 默认值: z16- Epsilon2.1
- Gantzert_Felixander
- haru01
- haru02
- haruto
- hibiki
- hijiki
- koharu
- miku
- nico
- ni-j
- nipsilon
- nito
- shizuku
- tororo
- tsumiki
- Unitychan
- wanko
- z16
-
width
: 宽度 默认值: 150 -
height
: 高度 默认值: 300 -
opacity
: 透明度 默认值: 0.9 -
mobileShow
: 是否在移动设备上显示 默认值: true -
mobileWidth
: 移动设备上的宽度 默认值: 75 -
mobileHeight
: 移动设备上的高度 默认值: 150 -
mobileOpacity
: 移动设备上的透明度 默认值: 0.8 -
position
: 模型左右侧放置位置left
或right
默认值: false -
horizontalOffset
:<canvas>
元素的水平偏移 默认值: 0 -
verticalOffset
:<canvas>
元素的底部偏移 默认值: -20 -
className
:<canvas>
元素的类名 默认值: live2d -
id
:<canvas>
元素的id 默认值: live2dcanvas 如果嫌模型位置不正确 可以调整这个参数
-
在博客的根目录下新建
live2d_models
文件夹 -
在此文件夹中以自定义模型的名称新建一个模型
-
将你的模型复制到该文件夹下
注意!模型json路径必须为 /live2d_models/{name}/{name}.model.json
示例:
你的模型为 mymiku
那么在 /
目录下(即博客的安装目录,该目录下应存在 _config.yml
、sources
、 themes
等内容) 新建名为 mymiku
的文件夹
将你的模型复制到 /live2d_models/mymiku/
下
此时在 /live2d_models/mymiku/
下应存在 mymiku.model.json
文件
请参见(#22)
Enjoy!:beer:
我第一个hexo插件,点个star,点个watch吧,尽情地交pr吧。
Github: https://github.com/EYHN/hexo-helper-live2d
issues: https://github.com/EYHN/hexo-helper-live2d/issues
注意!截图上方的名称可能非实际模型名,请进入“设置项”查看"model"的真实值
- 接入每日一句(json) 接入互动对话框(#16)
Open sourced under the GPL v2.0 license.
根据 GPL V2.0 许可证开源。