5 个版本
0.1.4 | 2023 年 8 月 5 日 |
---|---|
0.1.3 | 2023 年 7 月 11 日 |
0.1.2 | 2022 年 12 月 18 日 |
0.1.1 | 2022 年 11 月 1 日 |
0.1.0 | 2022 年 11 月 1 日 |
#929 在 文本处理
每月 235 次下载
26KB
184 代码行
mdbook-last-changed
为 mdbook 添加每页最后更改日期和提交链接的预处理器。
它添加一个“最后更改”页脚,包括日期和对应提交的链接。它使用配置的 git-repository-url
作为基础。
要求
- 需要
git
命令行工具。 - 在构建您的书时需要访问 git 仓库检出。
安装
如果您只想使用此预处理器,请安装此工具
cargo install mdbook-last-changed
将其添加到您的 book.toml
文件中的预处理器部分
[preprocessor.last-changed]
command = "mdbook-last-changed"
renderer = ["html"]
配置
mdbook-last-changed
使用 [output.html]
下的额外选项进行配置
[output.html]
# Optional: Your repository URL used in the link.
git-repository-url = "https://github.com/$user/$project"
如果未配置 git-repository-url
,则页脚将不会包含提交及其链接,而只显示最后更改日期。
未配置 git-repository-url
<footer id="last-change">Last change: 2023-07-09</footer>
配置了 git-repository-url
<footer id="last-change">Last change: 2023-07-09, commit: <a href="https://github.com/$user/$project/commit/$commit">0000000</a></footer>
要样式化页脚,请为您的 HTML 输出添加自定义 CSS 文件
[output.html]
additional-css = ["last-changed.css"]
并在 last-changed.css
中样式化 <footer>
元素或直接样式化 CSS 元素 ID last-changed
footer {
font-size: 0.8em;
text-align: center;
border-top: 1px solid black;
padding: 5px 0;
}
此代码块缩小文本大小,将其在内容下方居中排列,并在文本上方添加一条细小的水平线以将其与页面内容分隔开。
最后,按正常方式构建您的书
mdbook path/to/book
许可协议
MPL。请参阅 LICENSE。
版权所有 (c) 2022 Jan-Erik Rediger [email protected]
依赖项
~12–26MB
~343K SLoC