Skip to content

Commit

Permalink
feat: add paths.base config & paths config surpport http:// | https://
Browse files Browse the repository at this point in the history
  • Loading branch information
kitian616 committed Dec 10, 2017
1 parent 22181a1 commit ccc558d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
9 changes: 5 additions & 4 deletions _config.demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ nav_lists:
zh-Hant: 關於
url: /about.html

# paths:
# home: /
# all: /all.html
# rss: /feed.xml
paths:
base: /
home: https://github.com/kitian616/jekyll-TeXt-theme/
# all: /all.html
# rss: /feed.xml

## GitHub repository (if the site is hosted by GitHub) ##
repository: kitian616/jekyll-TeXt-theme
Expand Down
1 change: 1 addition & 0 deletions _config.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ nav_lists:
url: /about.html

paths:
base: /
home: /
all: /all.html
rss: /feed.xml
Expand Down
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ nav_lists:
url: /about.html

# paths:
# base: /
# home: /
# all: /all.html
# rss: /feed.xml
Expand Down
31 changes: 23 additions & 8 deletions _includes/blog/header.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,36 @@
<header class="m-page-header main clearfix">
{% if site.paths.home %}
{% assign __path = site.paths.home %}
{% if site.paths.base %}
{% assign __path = site.paths.base %}
{% else %}
{% assign __path = '/' %}
{% endif %}
{% include snippets/prepend-baseurl.html %}
{% 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 %}
{% if site.title %}
<a class="site-title" title="{% if site.description %}{{ site.description }}{% endif %}" href="{{ __return }}">{{ site.title }}</a>
<a class="site-title" title="{% if site.description %}{{ site.description }}{% endif %}" href="{{ __return }}">{{ site.title }}</a>
{% endif %}
<div class="site-logo">
{% include logo/logo.svg %}
</div>
<nav>
<ul class="inline-list">
{% assign __path = '/' %}
{% include snippets/prepend-baseurl.html %}
{% assign href = __return %}
{% if site.paths.home %}
{% assign __path = site.paths.home %}
{% 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 %}
{% assign __locale = site.data.locale.NAV.HOME %}
{% include snippets/locale-to-string.html %}
<li><a href="{{ href }}">{{ __return }}</a></li>
Expand All @@ -28,7 +43,7 @@
{% assign href = __return %}
{% assign __locale = site.data.locale.NAV.ALL %}
{% include snippets/locale-to-string.html %}
<li><a href="{{ href | append: "?tag=" | replace: '//', '/'}}">{{ __return }}</a></li>
<li><a href="{{ href }}">{{ __return }}</a></li>
{% for list in site.nav_lists %}
{% assign __path = list.url %}
{% include snippets/prepend-baseurl.html %}
Expand Down
1 change: 1 addition & 0 deletions test/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ nav_lists:
url: /about.html

# paths:
# base: /
# home: /
# all: /all.html
# rss: /feed.xml
Expand Down

0 comments on commit ccc558d

Please sign in to comment.