Skip to content

Commit

Permalink
site.paths & site.nav_lists support absolute url, close kitian616#21
Browse files Browse the repository at this point in the history
  • Loading branch information
kitian616 committed Jan 12, 2018
1 parent b7da2f8 commit 6517e31
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ TeXt 是针对博客的一款简洁的主题,它虽然简洁但并不简单。
- 网站图标的自动化工具([gulp-svg2png](https://www.npmjs.com/package/gulp-svg2png), [gulp-to-ico](https://www.npmjs.com/package/gulp-to-ico)
- Color Theme
- 数学公式([MathJax](https://www.mathjax.org/)
- 流程图, 序列图,甘特图([mermaid](https://mermaidjs.github.io/)
- RSS([jekyll-feed](https://github.com/jekyll/jekyll-feed)
- 多语言支持(English | 简体中文 | 繁體中文)

Expand Down
2 changes: 2 additions & 0 deletions _config.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ nav_lists:
zh-Hans: 关于
zh-Hant: 關於
url: /about.html
- title: Baidu
url: https://www.baidu.com

paths:
base: /
Expand Down
17 changes: 6 additions & 11 deletions _includes/blog/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{%- else -%}
{%- assign __path = '/' -%}
{%- endif -%}
{%- include snippets/prepend-baseurl.html -%}
{%- include snippets/get-nav-url.html -%}
{%- if site.title -%}
<a class="site-title" title="{%- if site.description -%}{{ site.description }}{%- endif -%}" href="{{ __return }}">{{ site.title }}</a>
{%- endif -%}
Expand All @@ -18,13 +18,8 @@
{%- else -%}
{%- assign __path = '/' -%}
{%- endif -%}
{%- assign pre7 = __path | slice: 0, 7 -%} {%- assign pre8 = __path | slice: 0, 8 -%}
{%- if pre7 == 'http://' or pre8 == 'https://' -%}
{%- assign href = __path -%}
{%- else -%}
{%- include snippets/prepend-baseurl.html -%}
{%- assign href = __return -%}
{%- endif -%}
{%- include snippets/get-nav-url.html -%}
{%- assign href = __return -%}
{%- assign __locale = site.data.locale.NAV.HOME -%}
{%- include snippets/locale-to-string.html -%}
<li><a href="{{ href }}">{{ __return }}</a></li>
Expand All @@ -33,14 +28,14 @@
{%- else -%}
{%- assign __path = '/all.html' -%}
{%- endif -%}
{%- include snippets/prepend-baseurl.html -%}
{%- include snippets/get-nav-url.html -%}
{%- assign href = __return -%}
{%- assign __locale = site.data.locale.NAV.ALL -%}
{%- include snippets/locale-to-string.html -%}
<li><a href="{{ href }}">{{ __return }}</a></li>
{%- for list in site.nav_lists -%}
{%- assign __path = list.url -%}
{%- include snippets/prepend-baseurl.html -%}
{%- include snippets/get-nav-url.html -%}
{%- assign href = __return -%}
{%- assign __locale = list.titles -%}
{%- include snippets/locale-to-string.html -%}
Expand All @@ -51,7 +46,7 @@
{%- else -%}
{%- assign __path = '/feed.xml' -%}
{%- endif -%}
{%- include snippets/prepend-baseurl.html -%}
{%- include snippets/get-nav-url.html -%}
{%- assign href = __return -%}
{%- assign __locale = site.data.locale.NAV.RSS -%}
{%- include snippets/locale-to-string.html -%}
Expand Down
7 changes: 7 additions & 0 deletions _includes/snippets/get-nav-url.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{%- assign pre7 = __path | slice: 0, 7 -%} {%- assign pre8 = __path | slice: 0, 8 -%}
{%- if pre7 == 'http://' or pre8 == 'https://' -%}
{%- assign __return = __path -%}
{%- else -%}
{%- include snippets/prepend-baseurl.html -%}
{%- assign __return = __return -%}
{%- endif -%}

0 comments on commit 6517e31

Please sign in to comment.