Skip to content

Commit baf5b21

Browse files
committed
404 多语言支持
1 parent 68cb8bb commit baf5b21

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

404.en.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
layout: splash
3+
---
4+
5+
<div class="notice--danger">
6+
<h1 id="">404</h1>
7+
<p><strong>Page Not Found</strong></p>
8+
</div>

404.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,15 @@ layout: splash
66
<h1 id="">404</h1>
77
<p><strong>页面不存在</strong></p>
88
</div>
9+
10+
<!----{{'>'}}
11+
<script>
12+
var pathname = location.pathname || "/";
13+
{%- for item in page.translations -%}
14+
{%- unless item[0] == site.locale %}
15+
if (pathname.indexOf("{{ '/' | relative_url }}{{ item[0] }}/") == 0) {
16+
location.href = "{{ '/' | relative_url }}{{ item[1].url | remove_first: "/" }}";
17+
}
18+
{%- endunless -%}
19+
{%- endfor -%}
20+
</script>

404.zh-TW.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
layout: splash
3+
---
4+
5+
<div class="notice--danger" id="not-found-content">
6+
<h1 id="">404</h1>
7+
<p><strong>頁麵不存在</strong></p>
8+
</div>

_config.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,6 @@ defaults:
123123
path: assets
124124
values:
125125
i18n: false
126-
- scope:
127-
path: 404.md
128-
values:
129-
i18n: false
130126
- scope:
131127
path: robots.txt
132128
values:

0 commit comments

Comments
 (0)