feat(head and body template): 支持在front-matter中动态插入css和js,支持引入多个 #883
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Type
Description
上述中的css代码会被插入到head.ejs中的这段位置
这样就能做到css或者js的动态加载,不需要将所有样式包全部怼进style.css里面;并且能在指定的页面插入js
用户使用需要注意,当你在某个页面中引入某些依赖于其他库比如jquery的的js,要确保你引入的js在jquery之后,可以通过浏览器调试查看;jquery在配置文件中plugins.globalJquery开启
传入单个文件,或者数组形式, 以上示例是单个字符串, 看一下数组的普遍使用场景,比如现在我们要生成一个二维码,利用
jquery-qrcode
插件首先要导入这个插件的js,还要写我们的业务代码。业务代码比较少,如果再另起一份js文件,显得有点大炮打蚊子,所以直接在script标签对中写代码即可。 注意yml格式的多行,换行用法, 这里自行百度
新建一个md页面,front-matter配置
打开这个页面, 看到二维码渲染成功
Others
Issue resolved:
Screenshots with this changes:
Link to demo site with this changes: