Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ccc558d

Browse files
committed
feat: add paths.base config & paths config surpport http:// | https://
1 parent 22181a1 commit ccc558d

File tree

5 files changed

+31
-12
lines changed

5 files changed

+31
-12
lines changed

‎_config.demo.yml‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ nav_lists:
2828
zh-Hant: 關於
2929
url: /about.html
3030

31-
# paths:
32-
# home: /
33-
# all: /all.html
34-
# rss: /feed.xml
31+
paths:
32+
base: /
33+
home: https://github.com/kitian616/jekyll-TeXt-theme/
34+
# all: /all.html
35+
# rss: /feed.xml
3536

3637
## GitHub repository (if the site is hosted by GitHub) ##
3738
repository: kitian616/jekyll-TeXt-theme

‎_config.dev.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ nav_lists:
2929
url: /about.html
3030

3131
paths:
32+
base: /
3233
home: /
3334
all: /all.html
3435
rss: /feed.xml

‎_config.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ nav_lists:
2727
url: /about.html
2828

2929
# paths:
30+
# base: /
3031
# home: /
3132
# all: /all.html
3233
# rss: /feed.xml

‎_includes/blog/header.html‎

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,36 @@
11
<header class="m-page-header main clearfix">
2-
{% if site.paths.home %}
3-
{% assign __path = site.paths.home %}
2+
{% if site.paths.base %}
3+
{% assign __path = site.paths.base %}
44
{% else %}
55
{% assign __path = '/' %}
66
{% endif %}
7-
{% include snippets/prepend-baseurl.html %}
7+
{% assign pre7 = __path | slice: 0, 7 %} {% assign pre8 = __path | slice: 0, 8 %}
8+
{% if pre7 == 'http://' or pre8 == 'https://' %}
9+
{% assign href = __path %}
10+
{% else %}
11+
{% include snippets/prepend-baseurl.html %}
12+
{% assign href = __return %}
13+
{% endif %}
814
{% if site.title %}
9-
<a class="site-title" title="{% if site.description %}{{ site.description }}{% endif %}" href="{{ __return }}">{{ site.title }}</a>
15+
<a class="site-title" title="{% if site.description %}{{ site.description }}{% endif %}" href="{{ __return }}">{{ site.title }}</a>
1016
{% endif %}
1117
<div class="site-logo">
1218
{% include logo/logo.svg %}
1319
</div>
1420
<nav>
1521
<ul class="inline-list">
16-
{% assign __path = '/' %}
17-
{% include snippets/prepend-baseurl.html %}
18-
{% assign href = __return %}
22+
{% if site.paths.home %}
23+
{% assign __path = site.paths.home %}
24+
{% else %}
25+
{% assign __path = '/' %}
26+
{% endif %}
27+
{% assign pre7 = __path | slice: 0, 7 %} {% assign pre8 = __path | slice: 0, 8 %}
28+
{% if pre7 == 'http://' or pre8 == 'https://' %}
29+
{% assign href = __path %}
30+
{% else %}
31+
{% include snippets/prepend-baseurl.html %}
32+
{% assign href = __return %}
33+
{% endif %}
1934
{% assign __locale = site.data.locale.NAV.HOME %}
2035
{% include snippets/locale-to-string.html %}
2136
<li><a href="{{ href }}">{{ __return }}</a></li>
@@ -28,7 +43,7 @@
2843
{% assign href = __return %}
2944
{% assign __locale = site.data.locale.NAV.ALL %}
3045
{% include snippets/locale-to-string.html %}
31-
<li><a href="{{ href | append: "?tag=" | replace: '//', '/'}}">{{ __return }}</a></li>
46+
<li><a href="{{ href }}">{{ __return }}</a></li>
3247
{% for list in site.nav_lists %}
3348
{% assign __path = list.url %}
3449
{% include snippets/prepend-baseurl.html %}

‎test/_config.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ nav_lists:
3131
url: /about.html
3232

3333
# paths:
34+
# base: /
3435
# home: /
3536
# all: /all.html
3637
# rss: /feed.xml

0 commit comments

Comments
 (0)