-
|
如题,假如我想添加 #1038 这里所说的 固定导航栏的 css 代码, 但是如果使用 npm 安装的话就不存在 themes/icarus 的目录。 看了hexo的注入器我感觉有点复杂,不是很懂前端,特意发帖问问 我参考了这个朋友的说法#867 (comment) ,在 观察打包后的 css 代码均位于 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
通过hexo5的注入器功能自定义博客js、css样式hexo注入器官方文档:https://hexo.io/zh-cn/api/injector.html 和参考的其他博主的博客链接:https://hexo.fluid-dev.com/posts/hexo-injector/ 。总共发现了两种方式: 方法一,先在根目录下 // scripts/inject.js
const css = hexo.extend.helper.get('css').bind(hexo);
const js = hexo.extend.helper.get('js').bind(hexo);
hexo.extend.injector.register('head_end', () => {
return css('/css/navbar.css');
});/* source/css/navbar.css */
.navbar {
z-index: 100;
position: sticky;
top: 0;
}方法二是直接在 hexo.extend.injector.register('head_end', () => `
<style>
/* 置顶导航栏样式 */
.navbar {
z-index: 100;
position: sticky;
top: 0;
}
</style>
`); |
Beta Was this translation helpful? Give feedback.
通过hexo5的注入器功能自定义博客js、css样式
hexo注入器官方文档:https://hexo.io/zh-cn/api/injector.html 和参考的其他博主的博客链接:https://hexo.fluid-dev.com/posts/hexo-injector/ 。总共发现了两种方式:
方法一,先在根目录下
scripts/inject.js文件;然后再去新建source/css/navbar.css文件。方法二是直接在
scripts/inject.js写入以下代码。