内置插件
内置插件 : https://github.com/enncy/easy-wiki/tree/main/plugins
使用npm i ewiki
命令安装后,则在./node_modules/ewiki/plugins
文件夹下
extra-widget
自动成侧边栏,顶部栏,以及主体内容
特殊配置 ewiki.config.json
.extra_widget_plugin
:
-
header_links :
Array
顶部栏链接列表 , html | text | img 三个字段为特殊字段,解析优先级为html
>text
>img
:- href :
string
链接地址 - target :
string
链接打开方式,默认_blank
- style :
string
标签样式 - attrs :
object
标签属性 - html :
string
a 标签中的 html 文本 - text :
string
a 标签中的文本 - img :
object
a 标签中的图片属性- src :
string
图片地址 - alt :
string
图片描述 - style :
string
图片样式
- src :
- href :
-
sidebar_links_group :
Array
侧边栏链接分组,如果有则会在侧边栏中生成分组- name :
string
分组名称 - links :
Array
分组链接列表。字段同上header-links
- name :
-
head_template :
string
模版文件路径,将追加到 head 标签中 -
body_template :
string
模版文件路径,将追加到 body 标签中 -
markdown_header_template :
string
模版文件路径,将追加到 markdown 内容的顶部 -
markdown_footer_template :
string
模版文件路径,将追加到 markdown 内容的底部
插件对四个模版提供了全局变量
{{METADATA.${key}}}
,${key}
为各个 md 文档文件上方的元数据的键,将会被替换为对应的值
示例
{
// "sources": [...],
// "plugins": [...],
// ... other config
"extra_widget_plugin": {
"header_links": [
{
"href": "https://github.com/enncy/easy-wiki",
"html": "<svg>xxx</svg>"
},
{
"text": "Github",
"href": "https://github.com/enncy/easy-wiki"
}
],
"sidebar_links_group": [
{
"name": "外链",
"links": [
{
"text": "Github",
"href": "https://github.com/enncy/easy-wiki"
}
]
}
],
"markdown_footer_template": "./templates/footer.html",
"markdown_header_template": "",
"head_template": "",
"body_template": ""
}
}
markdown_footer_template
模版文件示例
<div>
<hr />
<p>powered by <a href="https://github.com/enncy/easy-wiki"> easy-wiki </a></p>
<p>更新于:<span class="footer-time">{{METADATA.update_at}}</span></p>
<p>创建于:<span class="footer-time">{{METADATA.create_at}}</span></p>
<script>
window.addEventListener("load",()=>{
document.querySelectorAll(".footer-time").forEach((el)=>{
el.innerText = new Date(el.innerText).toLocaleString("zh-CN").replace(/\//g,'-')
})
})
</script>
</div>
custom-style-plugin
自定义样式插件,提供基础样式
md-container
自定义容器插件,对原有的 MarkdownIt 进行拓展,支持自定义容器,例如:
::: success abc
绿色容器
:::
::: info def
蓝色容器
:::
::: warn
黄色容器
:::
::: error
红色容器
:::
将被渲染成如下内容:
abc
绿色容器
def
蓝色容器
黄色容器
红色容器
pathfinder
路径解析插件,解析相对路径,例如:
./
,../xxx.md
解析为相应的文件,../xxx.md
将会被解析为对应的 html 文件链接
同样支持图片,视频等资源文件的相对路径解析