Hexo注入器
Hexo注入器
注入器被用于将静态代码片段注入生成的 HTML 的 <head> 和/或 <body> 中。Hexo 将在 after_render:html 过滤器 之前 完成注入。
概要
hexo.extend.injector.register(entry, value, to)entry <string>
代码片段注入的位置,接受以下值:
head_begin: 注入在<head>之后(默认)head_end: 注入在</head>之前body_begin: 注入在<body>之后body_end: 注入在</body>之前
value <string> | <Function>
除了字符串,也支持返回值为字符串的函数
需要注入的代码片段。
to <string>
需要注入代码片段的页面类型,接受以下值:
default: 注入到每个页面(默认值)home: 只注入到主页(is_home()为true的页面)post: 只注入到文章页面(is_post()为true的页面)page: 只注入到独立页面(is_page()为true的页面)archive: 只注入到归档页面(is_archive()为true的页面)category: 只注入到分类页面(is_category()为true的页面)tag: 只注入到标签页面(is_tag()为true的页面)- 或是其他自定义 layout 名称,自定义 layout 参见 写作 - 布局(Layout)
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 WenYan Blog!
评论









