UNPKG

gitbook-plugin-theme-cuav

Version:
73 lines (66 loc) 2.55 kB
{### Modified By 黄伟枞<weicong@cuav.net> Modify: 1. 修改插件获取的名字,将 theme-default 修改为 theme-cuav 2. 增加是否在 summary 底部显示 GitBook 链接 3. 增加链接是本地目录,但不存在时依旧显示链接 ###} {% macro articles(_articles) %} {% for article in _articles %} <li class="chapter {% if article.path == file.path and not article.anchor %}active{% endif %}" data-level="{{ article.level }}" {% if article.path %}data-path="{{ article.path|resolveFile }}"{% endif %}> {% if article.path and getPageByPath(article.path) %} <a href="{{ article.path|resolveFile }}{{ article.anchor }}"> {% elif article.url %} <a target="_blank" href="{{ article.url }}"> {% elif article.path and article.path|last=="\/" %} <a href="{{ article.path|truncate(article.path|length-1, True, '') }}"> {% else %} <span> {% endif %} {% if article.level != "0" and config.pluginsConfig['theme-cuav'].showLevel %} <b>{{ article.level }}.</b> {% endif %} {{ article.title }} {% if article.path or article.url %} </a> {% else %} </span> {% endif %} {% if article.articles.length > 0 %} <ul class="articles"> {{ articles(article.articles, file, config) }} </ul> {% endif %} </li> {% endfor %} {% endmacro %} <ul class="summary"> {% set _divider = false %} {% if config.links.sidebar %} {% for linkTitle, link in config.links.sidebar %} {% set _divider = true %} <li> <a href="{{ link }}" target="_blank" class="custom-link">{{ linkTitle }}</a> </li> {% endfor %} {% endif %} {% if _divider %} <li class="divider"></li> {% endif %} {% for part in summary.parts %} {% if part.title %} <li class="header">{{ part.title }}</li> {% elif not loop.first %} <li class="divider"></li> {% endif %} {{ articles(part.articles, file, config) }} {% endfor %} {%if config.pluginsConfig['theme-cuav'].showGitBookLink %} <li class="divider"></li> <li> <a href="https://www.gitbook.com" target="blank" class="gitbook-link"> {{ "GITBOOK_LINK"|t }} </a> </li> {% endif %} </ul>