用于选择器的根相对路径插件
lektor-root-relative-path的Python项目详细描述
lektor根相对路径插件
此插件返回从顶部页面到当前页面的根相对路径列表,如下所示。
[(toppage_url, toppage_name), ...(parent_url, parent_name), (url, name)]
安装
从命令行将lektor-root-relative-path
添加到项目中:
lektor plugins add lektor-root-relative-path
见the Lektor documentation for more instructions on installing plugins。
配置
在configs/root-relative-path.ini
:
导航页面名称
可选。导航中显示的首页名称。默认为“首页”
navi_top_page_name = 'Top Page'
如何使用
在要显示导航的模板(例如layout.html)中插入以下行。
{% for i in this._path | root_relative_path_list %}
>><a href="{{i[0]}}">{{i[1]}}</a>
{% endfor %}
然后,如果页面为“blog/first post/”,则导航如下所示
>>Top Page >>blog >>first-post
如果不想在导航中显示当前页,请按如下所示修改模板。
{% for i in this._path | root_relative_path_list %}
{% if not loop.last %}
>><a href="{{i[0]}}">{{i[1]}}</a>
{% endif %}
{% endfor %}
然后,导航如下图所示。
>>Top Page >>blog