perf(i18n): set the global default locales to "en" (#979)

Avoid missing labels caused by languages ​​outside of locales.
This commit is contained in:
Cotes Chung 2023-05-06 07:22:29 +08:00
parent aca79c1007
commit 61fdbcb83a
No known key found for this signature in database
GPG key ID: 0D9E54843167A808
23 changed files with 417 additions and 342 deletions

View file

@ -4,12 +4,16 @@
--> -->
{% assign wrap_elem = include.wrap | default: 'em' %} {% assign wrap_elem = include.wrap | default: 'em' %}
{% assign df_strftime = site.data.locales[site.lang].df.post.strftime | default: '%d/%m/%Y' %} {% assign df_strftime = site.data.locales[include.lang].df.post.strftime | default: '%d/%m/%Y' %}
{% assign df_dayjs = site.data.locales[site.lang].df.post.dayjs | default: 'DD/MM/YYYY' %} {% assign df_dayjs = site.data.locales[include.lang].df.post.dayjs | default: 'DD/MM/YYYY' %}
<{{ wrap_elem }} class="{% if include.class %}{{ include.class }}{% endif %}" <{{ wrap_elem }}
class="{% if include.class %}{{ include.class }}{% endif %}"
data-ts="{{ include.date | date: '%s' }}" data-ts="{{ include.date | date: '%s' }}"
data-df="{{ df_dayjs }}" data-df="{{ df_dayjs }}"
{% if include.tooltip %}data-toggle="tooltip" data-placement="bottom"{% endif %}> {% if include.tooltip %}
data-toggle="tooltip" data-placement="bottom"
{% endif %}
>
{{ include.date | date: df_strftime }} {{ include.date | date: df_strftime }}
</{{ wrap_elem }}> </{{ wrap_elem }}>

View file

@ -5,18 +5,22 @@
<div class="d-flex justify-content-between align-items-center text-muted ml-md-3 mr-md-3"> <div class="d-flex justify-content-between align-items-center text-muted ml-md-3 mr-md-3">
<div class="footer-left"> <div class="footer-left">
<p class="mb-0"> <p class="mb-0">
© {{ 'now' | date: "%Y" }} © {{ 'now' | date: '%Y' }}
<a href="{{ site.social.links[0] }}">{{ site.social.name }}</a>. <a href="{{ site.social.links[0] }}">{{ site.social.name }}</a>.
{% if site.data.locales[site.lang].copyright.brief %} {% if site.data.locales[include.lang].copyright.brief %}
<span data-toggle="tooltip" data-placement="top" <span
title="{{ site.data.locales[site.lang].copyright.verbose }}">{{ site.data.locales[site.lang].copyright.brief }}</span> data-toggle="tooltip"
data-placement="top"
title="{{ site.data.locales[include.lang].copyright.verbose }}"
>
{{- site.data.locales[include.lang].copyright.brief -}}
</span>
{% endif %} {% endif %}
</p> </p>
</div> </div>
<div class="footer-right"> <div class="footer-right">
<p class="mb-0"> <p class="mb-0">
{%- capture _platform -%} {%- capture _platform -%}
<a href="https://jekyllrb.com" target="_blank" rel="noopener">Jekyll</a> <a href="https://jekyllrb.com" target="_blank" rel="noopener">Jekyll</a>
{%- endcapture -%} {%- endcapture -%}
@ -25,9 +29,11 @@
<a href="https://github.com/cotes2020/jekyll-theme-chirpy" target="_blank" rel="noopener">Chirpy</a> <a href="https://github.com/cotes2020/jekyll-theme-chirpy" target="_blank" rel="noopener">Chirpy</a>
{%- endcapture -%} {%- endcapture -%}
{{ site.data.locales[site.lang].meta {{
site.data.locales[include.lang].meta
| default: 'Using the :PLATFORM theme :THEME.' | default: 'Using the :PLATFORM theme :THEME.'
| replace: ':PLATFORM', _platform | replace: ':THEME', _theme | replace: ':PLATFORM', _platform
| replace: ':THEME', _theme
}} }}
</p> </p>
</div> </div>

8
_includes/lang.html Normal file
View file

@ -0,0 +1,8 @@
{% comment %}
Detect appearance language and return it through variable "lang"
{% endcomment %}
{% if site.data.locales[site.lang] %}
{% assign lang = site.lang %}
{% else %}
{% assign lang = 'en' %}
{% endif %}

View file

@ -1,30 +1,37 @@
<!-- <!-- Navigation buttons at the bottom of the post. -->
Navigation buttons at the bottom of the post.
-->
<div class="post-navigation d-flex justify-content-between"> <div class="post-navigation d-flex justify-content-between">
{% if page.previous.url %} {% if page.previous.url %}
<a href="{{ site.baseurl }}{{ page.previous.url }}" class="btn btn-outline-primary" <a
prompt="{{ site.data.locales[site.lang].post.button.previous }}"> href="{{ site.baseurl }}{{ page.previous.url }}"
class="btn btn-outline-primary"
prompt="{{ site.data.locales[include.lang].post.button.previous }}"
>
<p>{{ page.previous.title }}</p> <p>{{ page.previous.title }}</p>
</a> </a>
{% else %} {% else %}
<div class="btn btn-outline-primary disabled" <div
prompt="{{ site.data.locales[site.lang].post.button.previous }}"> class="btn btn-outline-primary disabled"
prompt="{{ site.data.locales[include.lang].post.button.previous }}"
>
<p>-</p> <p>-</p>
</div> </div>
{% endif %} {% endif %}
{% if page.next.url %} {% if page.next.url %}
<a href="{{ site.baseurl }}{{page.next.url}}" class="btn btn-outline-primary" <a
prompt="{{ site.data.locales[site.lang].post.button.next }}"> href="{{ site.baseurl }}{{page.next.url}}"
class="btn btn-outline-primary"
prompt="{{ site.data.locales[include.lang].post.button.next }}"
>
<p>{{ page.next.title }}</p> <p>{{ page.next.title }}</p>
</a> </a>
{% else %} {% else %}
<div class="btn btn-outline-primary disabled" <div
prompt="{{ site.data.locales[site.lang].post.button.next }}"> class="btn btn-outline-primary disabled"
prompt="{{ site.data.locales[include.lang].post.button.next }}"
>
<p>-</p> <p>-</p>
</div> </div>
{% endif %} {% endif %}
</div> </div>

View file

@ -1,9 +1,7 @@
<!-- <!-- Post sharing snippet -->
Post sharing snippet
-->
<div class="share-wrapper"> <div class="share-wrapper">
<span class="share-label text-muted mr-1">{{ site.data.locales[site.lang].post.share }}</span> <span class="share-label text-muted mr-1">{{ site.data.locales[include.lang].post.share }}</span>
<span class="share-icons"> <span class="share-icons">
{% capture title %}{{ page.title }} - {{ site.title }}{% endcapture %} {% capture title %}{{ page.title }} - {{ site.title }}{% endcapture %}
{% assign title = title | uri_escape %} {% assign title = title | uri_escape %}
@ -11,17 +9,27 @@
{% for share in site.data.share.platforms %} {% for share in site.data.share.platforms %}
{% assign link = share.link | replace: 'TITLE', title | replace: 'URL', url %} {% assign link = share.link | replace: 'TITLE', title | replace: 'URL', url %}
<a href="{{ link }}" data-toggle="tooltip" data-placement="top" <a
title="{{ share.type }}" target="_blank" rel="noopener" aria-label="{{ share.type }}"> href="{{ link }}"
data-toggle="tooltip"
data-placement="top"
title="{{ share.type }}"
target="_blank"
rel="noopener"
aria-label="{{ share.type }}"
>
<i class="fa-fw {{ share.icon }}"></i> <i class="fa-fw {{ share.icon }}"></i>
</a> </a>
{% endfor %} {% endfor %}
<i id="copy-link" class="fa-fw fas fa-link small" <i
data-toggle="tooltip" data-placement="top" id="copy-link"
title="{{ site.data.locales[site.lang].post.button.share_link.title }}" class="fa-fw fas fa-link small"
data-title-succeed="{{ site.data.locales[site.lang].post.button.share_link.succeed }}"> data-toggle="tooltip"
data-placement="top"
title="{{ site.data.locales[include.lang].post.button.share_link.title }}"
data-title-succeed="{{ site.data.locales[include.lang].post.button.share_link.succeed }}"
>
</i> </i>
</span> </span>
</div> </div>

View file

@ -1,8 +1,6 @@
<!-- <!-- Calculate the post's reading time, and display the word count in tooltip -->
Calculate the post's reading time, and display the word count in tooltip
-->
{% assign words = include.content | strip_html | number_of_words: "auto" %} {% assign words = include.content | strip_html | number_of_words: 'auto' %}
<!-- words per minute --> <!-- words per minute -->
@ -16,15 +14,24 @@
{% endunless %} {% endunless %}
{% capture read_prompt %} {% capture read_prompt %}
{{- site.data.locales[site.lang].post.read_time.prompt -}} {{- site.data.locales[include.lang].post.read_time.prompt -}}
{% endcapture %} {% endcapture %}
<!-- return element --> <!-- return element -->
<span class="readtime" data-toggle="tooltip" data-placement="bottom" <span
title="{{ words }} {{ site.data.locales[site.lang].post.words }}"> class="readtime"
<em>{{- read_time -}}{{" "}}{{- site.data.locales[site.lang].post.read_time.unit -}}</em> data-toggle="tooltip"
data-placement="bottom"
title="{{ words }} {{ site.data.locales[include.lang].post.words }}"
>
<em>
{{- read_time -}}
{{ ' ' }}
{{- site.data.locales[include.lang].post.read_time.unit -}}
</em>
{%- if include.prompt -%} {%- if include.prompt -%}
{%- assign _prompt_words = read_prompt | number_of_words: 'auto' -%} {%- assign _prompt_words = read_prompt | number_of_words: 'auto' -%}
{%- unless _prompt_words > 1 -%}{{ " " }}{%- endunless -%}{{ read_prompt }} {%- unless _prompt_words > 1 -%}{{ ' ' }}{%- endunless -%}
{{ read_prompt }}
{%- endif -%} {%- endif -%}
</span> </span>

View file

@ -225,7 +225,7 @@
| append: '<div class="code-header">' | append: '<div class="code-header">'
| append: _label | append: _label
| append: '<button aria-label="copy" data-title-succeed="' | append: '<button aria-label="copy" data-title-succeed="'
| append: site.data.locales[site.lang].post.button.copy_code.succeed | append: site.data.locales[include.lang].post.button.copy_code.succeed
| append: '"><i class="far fa-clipboard"></i></button></div>' | append: '"><i class="far fa-clipboard"></i></button></div>'
| append: '<div class="highlight"><code>' | append: '<div class="highlight"><code>'
%} %}

View file

@ -12,9 +12,9 @@
<!-- Equals to TAG_SCORE / {max_categories_hierarchy} --> <!-- Equals to TAG_SCORE / {max_categories_hierarchy} -->
{% assign CATEGORY_SCORE = 0.5 %} {% assign CATEGORY_SCORE = 0.5 %}
{% assign SEPARATOR = ":" %} {% assign SEPARATOR = ':' %}
{% assign score_list = "" | split: "" %} {% assign score_list = '' | split: '' %}
{% assign last_index = site.posts.size | minus: 1 %} {% assign last_index = site.posts.size | minus: 1 %}
{% for i in (0..last_index) %} {% for i in (0..last_index) %}
@ -42,11 +42,9 @@
{% capture score_item %}{{ score }}{{ SEPARATOR }}{{ i }}{% endcapture %} {% capture score_item %}{{ score }}{{ SEPARATOR }}{{ i }}{% endcapture %}
{% assign score_list = score_list | push: score_item %} {% assign score_list = score_list | push: score_item %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% assign index_list = '' | split: '' %}
{% assign index_list = "" | split: "" %}
{% if score_list.size > 0 %} {% if score_list.size > 0 %}
{% assign score_list = score_list | sort | reverse %} {% assign score_list = score_list | sort | reverse %}
@ -77,8 +75,12 @@
{% if index_list.size > 0 %} {% if index_list.size > 0 %}
<div id="related-posts" class="mb-2 mb-sm-4"> <div id="related-posts" class="mb-2 mb-sm-4">
<h3 class="pt-2 mb-4 ml-1" <h3
data-toc-skip>{{ site.data.locales[site.lang].post.relate_posts }}</h3> class="pt-2 mb-4 ml-1"
data-toc-skip
>
{{ site.data.locales[include.lang].post.relate_posts }}
</h3>
<div class="card-deck mb-4"> <div class="card-deck mb-4">
{% for entry in index_list %} {% for entry in index_list %}
{% assign index = entry | plus: 0 %} {% assign index = entry | plus: 0 %}
@ -86,7 +88,7 @@
<div class="card"> <div class="card">
<a href="{{ post.url | relative_url }}"> <a href="{{ post.url | relative_url }}">
<div class="card-body"> <div class="card-body">
{% include datetime.html date=post.date class="small" %} {% include datetime.html date=post.date class="small" lang=include.lang %}
<h3 class="pt-0 mt-1 mb-3" data-toc-skip>{{ post.title }}</h3> <h3 class="pt-0 mt-1 mb-3" data-toc-skip>{{ post.title }}</h3>
<div class="text-muted small"> <div class="text-muted small">
<p> <p>
@ -98,6 +100,8 @@
</a> </a>
</div> </div>
{% endfor %} {% endfor %}
</div> <!-- .card-deck --> </div>
</div> <!-- #related-posts --> <!-- .card-deck -->
</div>
<!-- #related-posts -->
{% endif %} {% endif %}

View file

@ -14,7 +14,7 @@
</div> </div>
{% endcapture %} {% endcapture %}
{% capture not_found %}<p class="mt-5">{{ site.data.locales[site.lang].search.no_results }}</p>{% endcapture %} {% capture not_found %}<p class="mt-5">{{ site.data.locales[include.lang].search.no_results }}</p>{% endcapture %}
<script src="{{ site.data.assets[origin].search.js | relative_url }}"></script> <script src="{{ site.data.assets[origin].search.js | relative_url }}"></script>

View file

@ -1,6 +1,4 @@
<!-- <!-- The Side Bar -->
The Side Bar
-->
<div id="sidebar" class="d-flex flex-column align-items-end"> <div id="sidebar" class="d-flex flex-column align-items-end">
<div class="profile-wrapper text-center"> <div class="profile-wrapper text-center">
@ -25,16 +23,15 @@
<a href="{{ '/' | relative_url }}">{{ site.title }}</a> <a href="{{ '/' | relative_url }}">{{ site.title }}</a>
</div> </div>
<div class="site-subtitle font-italic">{{ site.tagline }}</div> <div class="site-subtitle font-italic">{{ site.tagline }}</div>
</div>
</div><!-- .profile-wrapper --> <!-- .profile-wrapper -->
<ul class="w-100"> <ul class="w-100">
<!-- home --> <!-- home -->
<li class="nav-item{% if page.layout == 'home' %}{{ " active" }}{% endif %}"> <li class="nav-item{% if page.layout == 'home' %}{{ " active" }}{% endif %}">
<a href="{{ '/' | relative_url }}" class="nav-link"> <a href="{{ '/' | relative_url }}" class="nav-link">
<i class="fa-fw fas fa-home ml-xl-3 mr-xl-3 unloaded"></i> <i class="fa-fw fas fa-home ml-xl-3 mr-xl-3 unloaded"></i>
<span>{{ site.data.locales[site.lang].tabs.home | upcase }}</span> <span>{{ site.data.locales[include.lang].tabs.home | upcase }}</span>
</a> </a>
</li> </li>
<!-- the real tabs --> <!-- the real tabs -->
@ -44,15 +41,15 @@
<i class="fa-fw {{ tab.icon }} ml-xl-3 mr-xl-3 unloaded"></i> <i class="fa-fw {{ tab.icon }} ml-xl-3 mr-xl-3 unloaded"></i>
{% capture tab_name %}{{ tab.url | split: '/' }}{% endcapture %} {% capture tab_name %}{{ tab.url | split: '/' }}{% endcapture %}
<span>{{ site.data.locales[site.lang].tabs.[tab_name] | default: tab.title | upcase }}</span> <span>{{ site.data.locales[include.lang].tabs.[tab_name] | default: tab.title | upcase }}</span>
</a> </a>
</li> <!-- .nav-item --> </li>
<!-- .nav-item -->
{% endfor %} {% endfor %}
</ul>
</ul> <!-- ul.nav.flex-column --> <!-- ul.nav.flex-column -->
<div class="sidebar-bottom mt-auto d-flex flex-wrap justify-content-center align-items-center"> <div class="sidebar-bottom mt-auto d-flex flex-wrap justify-content-center align-items-center">
{% unless site.theme_mode %} {% unless site.theme_mode %}
<button class="mode-toggle btn" aria-label="Switch Mode"> <button class="mode-toggle btn" aria-label="Switch Mode">
<i class="fas fa-adjust"></i> <i class="fas fa-adjust"></i>
@ -81,7 +78,9 @@
{% endcase %} {% endcase %}
{% if url %} {% if url %}
<a href="{{ url }}" aria-label="{{ entry.type }}" <a
href="{{ url }}"
aria-label="{{ entry.type }}"
{% assign link_types = '' %} {% assign link_types = '' %}
{% unless entry.noblank %} {% unless entry.noblank %}
@ -93,14 +92,15 @@
{% assign link_types = link_types | append: ' me' | strip %} {% assign link_types = link_types | append: ' me' | strip %}
{% endif %} {% endif %}
{% unless link_types == empty %}rel="{{ link_types }}"{% endunless %}> {% unless link_types == empty %}
rel="{{ link_types }}"
{% endunless %}
>
<i class="{{ entry.icon }}"></i> <i class="{{ entry.icon }}"></i>
</a> </a>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</div>
</div> <!-- .sidebar-bottom --> <!-- .sidebar-bottom -->
</div>
</div><!-- #sidebar --> <!-- #sidebar -->

View file

@ -7,7 +7,7 @@
{% if enable_toc %} {% if enable_toc %}
<div id="toc-wrapper" class="pl-0 pr-4 mb-5"> <div id="toc-wrapper" class="pl-0 pr-4 mb-5">
<div class="panel-heading pl-3 pt-2 mb-2">{{- site.data.locales[site.lang].panel.toc -}}</div> <div class="panel-heading pl-3 pt-2 mb-2">{{- site.data.locales[include.lang].panel.toc -}}</div>
<nav id="toc"></nav> <nav id="toc"></nav>
</div> </div>

View file

@ -1,32 +1,26 @@
<!-- <!-- The Top Bar -->
The Top Bar
-->
<div id="topbar-wrapper"> <div id="topbar-wrapper">
<div id="topbar" class="container d-flex align-items-center justify-content-between h-100 pl-3 pr-3 pl-md-4 pr-md-4"> <div id="topbar" class="container d-flex align-items-center justify-content-between h-100 pl-3 pr-3 pl-md-4 pr-md-4">
<span id="breadcrumb"> <span id="breadcrumb">
{% assign paths = page.url | split: '/' %} {% assign paths = page.url | split: '/' %}
{% if paths.size == 0 or page.layout == 'home' %} {% if paths.size == 0 or page.layout == 'home' %}
<!-- index page --> <!-- index page -->
<span>{{ site.data.locales[site.lang].tabs.home | capitalize }}</span> <span>{{ site.data.locales[include.lang].tabs.home | capitalize }}</span>
{% else %} {% else %}
{% for item in paths %} {% for item in paths %}
{% if forloop.first %} {% if forloop.first %}
<span> <span>
<a href="{{ '/' | relative_url }}"> <a href="{{ '/' | relative_url }}">
{{ site.data.locales[site.lang].tabs.home | capitalize }} {{ site.data.locales[include.lang].tabs.home | capitalize }}
</a> </a>
</span> </span>
{% elsif forloop.last %} {% elsif forloop.last %}
{% if page.collection == 'tabs' %} {% if page.collection == 'tabs' %}
<span>{{ site.data.locales[site.lang].tabs[item] | default: page.title }}</span> <span>{{ site.data.locales[include.lang].tabs[item] | default: page.title }}</span>
{% else %} {% else %}
<span>{{ page.title }}</span> <span>{{ page.title }}</span>
{% endif %} {% endif %}
@ -34,37 +28,40 @@
{% elsif page.layout == 'category' or page.layout == 'tag' %} {% elsif page.layout == 'category' or page.layout == 'tag' %}
<span> <span>
<a href="{{ item | relative_url }}"> <a href="{{ item | relative_url }}">
{{ site.data.locales[site.lang].tabs[item] | default: page.title }} {{ site.data.locales[include.lang].tabs[item] | default: page.title }}
</a> </a>
</span> </span>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
</span>
</span><!-- endof #breadcrumb --> <!-- endof #breadcrumb -->
<i id="sidebar-trigger" class="fas fa-bars fa-fw"></i> <i id="sidebar-trigger" class="fas fa-bars fa-fw"></i>
<div id="topbar-title"> <div id="topbar-title">
{% if page.layout == 'home' %} {% if page.layout == 'home' %}
{{- site.data.locales[site.lang].title | default: site.title -}} {{- site.data.locales[include.lang].title | default: site.title -}}
{% elsif page.collection == 'tabs' or page.layout == 'page' %} {% elsif page.collection == 'tabs' or page.layout == 'page' %}
{%- capture tab_key -%}{{ page.url | split: '/' }}{%- endcapture -%} {%- capture tab_key -%}{{ page.url | split: '/' }}{%- endcapture -%}
{{- site.data.locales[site.lang].tabs[tab_key] | default: page.title -}} {{- site.data.locales[include.lang].tabs[tab_key] | default: page.title -}}
{% else %} {% else %}
{{- site.data.locales[site.lang].layout[page.layout] | default: page.layout | capitalize -}} {{- site.data.locales[include.lang].layout[page.layout] | default: page.layout | capitalize -}}
{% endif %} {% endif %}
</div> </div>
<i id="search-trigger" class="fas fa-search fa-fw"></i> <i id="search-trigger" class="fas fa-search fa-fw"></i>
<span id="search-wrapper" class="align-items-center"> <span id="search-wrapper" class="align-items-center">
<i class="fas fa-search fa-fw"></i> <i class="fas fa-search fa-fw"></i>
<input class="form-control" id="search-input" type="search" <input
aria-label="search" autocomplete="off" placeholder="{{ site.data.locales[site.lang].search.hint | capitalize }}..."> class="form-control"
id="search-input"
type="search"
aria-label="search"
autocomplete="off"
placeholder="{{ site.data.locales[include.lang].search.hint | capitalize }}..."
>
</span> </span>
<span id="search-cancel" >{{ site.data.locales[site.lang].search.cancel }}</span> <span id="search-cancel">{{ site.data.locales[include.lang].search.cancel }}</span>
</div> </div>
</div> </div>

View file

@ -4,14 +4,14 @@
{% assign MAX = 10 %} {% assign MAX = 10 %}
{% assign size_list = "" | split: "" %} {% assign size_list = '' | split: '' %}
{% assign tag_list = "" | split: "" %} {% assign tag_list = '' | split: '' %}
{% for tag in site.tags %} {% for tag in site.tags %}
{% assign size = tag | last | size %} {% assign size = tag | last | size %}
{% assign size_list = size_list | push: size %} {% assign size_list = size_list | push: size %}
{% assign tag_str = tag | first | append: "::" | append: size %} {% assign tag_str = tag | first | append: '::' | append: size %}
{% assign tag_list = tag_list | push: tag_str %} {% assign tag_list = tag_list | push: tag_str %}
{% endfor %} {% endfor %}
@ -19,11 +19,11 @@
{% assign tag_list = tag_list | sort_natural %} {% assign tag_list = tag_list | sort_natural %}
{% assign trending_tags = "" | split: "" %} {% assign trending_tags = '' | split: '' %}
{% for size in size_list limit: MAX %} {% for size in size_list limit: MAX %}
{% for tag_str in tag_list %} {% for tag_str in tag_list %}
{% assign tag = tag_str | split: "::" %} {% assign tag = tag_str | split: '::' %}
{% assign tag_name = tag | first %} {% assign tag_name = tag | first %}
{% assign tag_size = tag | last | plus: 0 %} {% assign tag_size = tag | last | plus: 0 %}
{% if tag_size == size %} {% if tag_size == size %}
@ -37,14 +37,12 @@
{% if trending_tags.size > 0 %} {% if trending_tags.size > 0 %}
<div id="access-tags"> <div id="access-tags">
<div class="panel-heading">{{- site.data.locales[site.lang].panel.trending_tags -}}</div> <div class="panel-heading">{{- site.data.locales[include.lang].panel.trending_tags -}}</div>
<div class="d-flex flex-wrap mt-3 mb-1 mr-3"> <div class="d-flex flex-wrap mt-3 mb-1 mr-3">
{% for tag_name in trending_tags %} {% for tag_name in trending_tags %}
{% assign url = tag_name | slugify | url_encode | prepend: "/tags/" | append: "/" %} {% assign url = tag_name | slugify | url_encode | prepend: '/tags/' | append: '/' %}
<a class="post-tag" href="{{ url | relative_url }}">{{ tag_name }}</a> <a class="post-tag" href="{{ url | relative_url }}">{{ tag_name }}</a>
{% endfor %} {% endfor %}
</div> </div>
</div> </div>
{% endif %} {% endif %}

View file

@ -4,7 +4,7 @@
{% assign MAX_SIZE = 5 %} {% assign MAX_SIZE = 5 %}
{% assign all_list = "" | split: "" %} {% assign all_list = '' | split: '' %}
{% for post in site.posts %} {% for post in site.posts %}
{% if post.last_modified_at %} {% if post.last_modified_at %}
@ -17,24 +17,25 @@
{% assign all_list = all_list | sort | reverse %} {% assign all_list = all_list | sort | reverse %}
{% assign update_list = "" | split: "" %} {% assign update_list = '' | split: '' %}
{% for entry in all_list limit: MAX_SIZE %} {% for entry in all_list limit: MAX_SIZE %}
{% assign update_list = update_list | push: entry %} {% assign update_list = update_list | push: entry %}
{% endfor %} {% endfor %}
{% if update_list.size > 0 %} {% if update_list.size > 0 %}
<div id="access-lastmod" class="post"> <div id="access-lastmod" class="post">
<div class="panel-heading">{{- site.data.locales[site.lang].panel.lastmod -}}</div> <div class="panel-heading">{{- site.data.locales[include.lang].panel.lastmod -}}</div>
<ul class="post-content pl-0 pb-1 ml-1 mt-2"> <ul class="post-content pl-0 pb-1 ml-1 mt-2">
{% for item in update_list %} {% for item in update_list %}
{% assign index = item | split: "::" | last | plus: 0 %} {% assign index = item | split: '::' | last | plus: 0 %}
{% assign post = site.posts[index] %} {% assign post = site.posts[index] %}
{% assign url = post.url | relative_url %} {% assign url = post.url | relative_url %}
<li><a href="{{ url }}">{{ post.title }}</a></li> <li>
<a href="{{ url }}">{{ post.title }}</a>
</li>
{% endfor %} {% endfor %}
</ul> </ul>
</div> <!-- #access-lastmod --> </div>
<!-- #access-lastmod -->
{% endif %} {% endif %}

View file

@ -3,8 +3,10 @@ layout: page
# The Archives of posts. # The Archives of posts.
--- ---
{% assign df_strftime_m = site.data.locales[site.lang].df.archives.strftime | default: '/ %m' %} {% include lang.html %}
{% assign df_dayjs_m = site.data.locales[site.lang].df.archives.dayjs | default: '/ MM' %}
{% assign df_strftime_m = site.data.locales[lang].df.archives.strftime | default: '/ %m' %}
{% assign df_dayjs_m = site.data.locales[lang].df.archives.dayjs | default: '/ MM' %}
<div id="archives" class="pl-xl-3"> <div id="archives" class="pl-xl-3">

View file

@ -3,8 +3,10 @@ layout: page
# All the Categories of posts # All the Categories of posts
--- ---
{% assign HEAD_PREFIX = "h_" %} {% include lang.html %}
{% assign LIST_PREFIX = "l_" %}
{% assign HEAD_PREFIX = 'h_' %}
{% assign LIST_PREFIX = 'l_' %}
{% assign group_index = 0 %} {% assign group_index = 0 %}
@ -16,7 +18,7 @@ layout: page
{% assign first_post = posts_of_category | first %} {% assign first_post = posts_of_category | first %}
{% if category_name == first_post.categories[0] %} {% if category_name == first_post.categories[0] %}
{% assign sub_categories = "" | split: "" %} {% assign sub_categories = '' | split: '' %}
{% for post in posts_of_category %} {% for post in posts_of_category %}
{% assign second_category = post.categories[1] %} {% assign second_category = post.categories[1] %}
@ -32,8 +34,10 @@ layout: page
<div class="card categories"> <div class="card categories">
<!-- top-category --> <!-- top-category -->
<div id="{{ HEAD_PREFIX }}{{ group_index }}" <div
class="card-header d-flex justify-content-between hide-border-bottom"> id="{{ HEAD_PREFIX }}{{ group_index }}"
class="card-header d-flex justify-content-between hide-border-bottom"
>
<span> <span>
<i class="far fa-folder{% if sub_categories_size > 0 %}-open{% endif %} fa-fw"></i> <i class="far fa-folder{% if sub_categories_size > 0 %}-open{% endif %} fa-fw"></i>
@ -46,31 +50,44 @@ layout: page
{% if sub_categories_size > 0 %} {% if sub_categories_size > 0 %}
{{ sub_categories_size }} {{ sub_categories_size }}
{% if sub_categories_size > 1 %} {% if sub_categories_size > 1 %}
{{ site.data.locales[site.lang].categories.category_measure.plural {{
| default: site.data.locales[site.lang].categories.category_measure }} site.data.locales[lang].categories.category_measure.plural
| default: site.data.locales[lang].categories.category_measure
}}
{% else %} {% else %}
{{ site.data.locales[site.lang].categories.category_measure.singular {{
| default: site.data.locales[site.lang].categories.category_measure }} site.data.locales[lang].categories.category_measure.singular
{% endif %}, | default: site.data.locales[lang].categories.category_measure
}}
{% endif -%}
,
{% endif %} {% endif %}
{{ top_posts_size }} {{ top_posts_size }}
{% if top_posts_size > 1 %} {% if top_posts_size > 1 %}
{{ site.data.locales[site.lang].categories.post_measure.plural {{
| default: site.data.locales[site.lang].categories.post_measure }} site.data.locales[lang].categories.post_measure.plural
| default: site.data.locales[lang].categories.post_measure
}}
{% else %} {% else %}
{{ site.data.locales[site.lang].categories.post_measure.singular {{
| default: site.data.locales[site.lang].categories.post_measure }} site.data.locales[lang].categories.post_measure.singular
| default: site.data.locales[lang].categories.post_measure
}}
{% endif %} {% endif %}
</span> </span>
</span> </span>
<!-- arrow --> <!-- arrow -->
{% if sub_categories_size > 0 %} {% if sub_categories_size > 0 %}
<a href="#{{ LIST_PREFIX }}{{ group_index }}" data-toggle="collapse" <a
aria-expanded="true" aria-label="{{ HEAD_PREFIX }}{{ group_index }}-trigger" href="#{{ LIST_PREFIX }}{{ group_index }}"
class="category-trigger hide-border-bottom"> data-toggle="collapse"
aria-expanded="true"
aria-label="{{ HEAD_PREFIX }}{{ group_index }}-trigger"
class="category-trigger hide-border-bottom"
>
<i class="fas fa-fw fa-angle-down"></i> <i class="fas fa-fw fa-angle-down"></i>
</a> </a>
{% else %} {% else %}
@ -78,8 +95,8 @@ layout: page
<i class="fas fa-fw fa-angle-right"></i> <i class="fas fa-fw fa-angle-right"></i>
</span> </span>
{% endif %} {% endif %}
</div>
</div> <!-- .card-header --> <!-- .card-header -->
<!-- Sub-categories --> <!-- Sub-categories -->
{% if sub_categories_size > 0 %} {% if sub_categories_size > 0 %}
@ -97,11 +114,15 @@ layout: page
{{ posts_size }} {{ posts_size }}
{% if posts_size > 1 %} {% if posts_size > 1 %}
{{ site.data.locales[site.lang].categories.post_measure.plural {{
| default: site.data.locales[site.lang].categories.post_measure }} site.data.locales[lang].categories.post_measure.plural
| default: site.data.locales[lang].categories.post_measure
}}
{% else %} {% else %}
{{ site.data.locales[site.lang].categories.post_measure.singular {{
| default: site.data.locales[site.lang].categories.post_measure }} site.data.locales[lang].categories.post_measure.singular
| default: site.data.locales[lang].categories.post_measure
}}
{% endif %} {% endif %}
</span> </span>
</li> </li>
@ -109,10 +130,9 @@ layout: page
</ul> </ul>
</div> </div>
{% endif %} {% endif %}
</div>
</div> <!-- .card --> <!-- .card -->
{% assign group_index = group_index | plus: 1 %} {% assign group_index = group_index | plus: 1 %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}

View file

@ -3,6 +3,8 @@ layout: page
# The Category layout # The Category layout
--- ---
{% include lang.html %}
<div id="page-category"> <div id="page-category">
<h1 class="pl-lg-2"> <h1 class="pl-lg-2">
<i class="far fa-folder-open fa-fw text-muted"></i> <i class="far fa-folder-open fa-fw text-muted"></i>
@ -15,7 +17,7 @@ layout: page
<li class="d-flex justify-content-between pl-md-3 pr-md-3"> <li class="d-flex justify-content-between pl-md-3 pr-md-3">
<a href="{{ post.url | relative_url }}">{{ post.title }}</a> <a href="{{ post.url | relative_url }}">{{ post.title }}</a>
<span class="dash flex-grow-1"></span> <span class="dash flex-grow-1"></span>
{% include datetime.html date=post.date wrap='span' class='text-muted small' %} {% include datetime.html date=post.date wrap='span' class='text-muted small' lang=lang %}
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>

View file

@ -3,10 +3,12 @@ layout: compress
# Default layout # Default layout
--- ---
<!DOCTYPE html> <!doctype html>
{% include assets-origin.html %} {% include assets-origin.html %}
{% include lang.html %}
{% capture prefer_mode %} {% capture prefer_mode %}
{% if site.theme_mode %} {% if site.theme_mode %}
data-mode="{{ site.theme_mode }}" data-mode="{{ site.theme_mode }}"
@ -15,25 +17,23 @@ layout: compress
<!-- `site.alt_lang` can specify a language different from the UI --> <!-- `site.alt_lang` can specify a language different from the UI -->
<html lang="{{ site.alt_lang | default: site.lang }}" {{ prefer_mode }}> <html lang="{{ site.alt_lang | default: site.lang }}" {{ prefer_mode }}>
{% include head.html %} {% include head.html %}
<body data-topbar-visible="true"> <body data-topbar-visible="true">
{% include sidebar.html lang=lang %}
{% include sidebar.html %} {% include topbar.html lang=lang %}
{% include topbar.html %}
<div id="main-wrapper" class="d-flex justify-content-center"> <div id="main-wrapper" class="d-flex justify-content-center">
<div id="main" class="container pl-xl-4 pr-xl-4"> <div id="main" class="container pl-xl-4 pr-xl-4">
{{ content }} {{ content }}
</div> </div>
{% include search-results.html %} {% include search-results.html lang=lang %}
</div>
<!-- #main-wrapper -->
</div> <!-- #main-wrapper --> {% include footer.html lang=lang %}
{% include footer.html %}
{% if page.mermaid %} {% if page.mermaid %}
{% include mermaid.html %} {% include mermaid.html %}
@ -46,17 +46,24 @@ layout: compress
</a> </a>
{% if site.pwa.enabled %} {% if site.pwa.enabled %}
<div id="notification" class="toast" role="alert" aria-live="assertive" aria-atomic="true" <div
data-animation="true" data-autohide="false"> id="notification"
class="toast"
role="alert"
aria-live="assertive"
aria-atomic="true"
data-animation="true"
data-autohide="false"
>
<div class="toast-header"> <div class="toast-header">
<button type="button" class="ml-2 ml-auto close" data-dismiss="toast" aria-label="Close"> <button type="button" class="ml-2 ml-auto close" data-dismiss="toast" aria-label="Close">
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
</div> </div>
<div class="toast-body text-center pt-0"> <div class="toast-body text-center pt-0">
<p class="pl-2 pr-2 mb-3">{{ site.data.locales[site.lang].notification.update_found }}</p> <p class="pl-2 pr-2 mb-3">{{ site.data.locales[lang].notification.update_found }}</p>
<button type="button" class="btn btn-primary" aria-label="Update"> <button type="button" class="btn btn-primary" aria-label="Update">
{{ site.data.locales[site.lang].notification.update }} {{ site.data.locales[lang].notification.update }}
</button> </button>
</div> </div>
</div> </div>
@ -65,7 +72,5 @@ layout: compress
{% include search-loader.html %} {% include search-loader.html %}
{% include js-selector.html %} {% include js-selector.html %}
</body> </body>
</html> </html>

View file

@ -3,6 +3,8 @@ layout: page
# The Home page layout # The Home page layout
--- ---
{% include lang.html %}
{% assign pinned = site.posts | where: 'pin', 'true' %} {% assign pinned = site.posts | where: 'pin', 'true' %}
{% assign default = site.posts | where_exp: 'item', 'item.pin != true and item.hidden != true' %} {% assign default = site.posts | where_exp: 'item', 'item.pin != true and item.hidden != true' %}
@ -58,7 +60,7 @@ layout: page
<div class="mr-auto"> <div class="mr-auto">
<!-- posted date --> <!-- posted date -->
<i class="far fa-calendar fa-fw"></i> <i class="far fa-calendar fa-fw"></i>
{% include datetime.html date=post.date %} {% include datetime.html date=post.date lang=lang %}
<!-- categories --> <!-- categories -->
{% if post.categories.size > 0 %} {% if post.categories.size > 0 %}
@ -75,7 +77,7 @@ layout: page
{% if post.pin %} {% if post.pin %}
<div class="pin"> <div class="pin">
<i class="fas fa-thumbtack fa-fw"></i> <i class="fas fa-thumbtack fa-fw"></i>
<span>{{ site.data.locales[site.lang].post.pin_prompt }}</span> <span>{{ site.data.locales[lang].post.pin_prompt }}</span>
</div> </div>
{% endif %} {% endif %}
</div> </div>

View file

@ -4,15 +4,15 @@ layout: default
{% include assets-origin.html %} {% include assets-origin.html %}
<div class="row"> {% include lang.html %}
<div class="row">
<!-- core --> <!-- core -->
<div id="core-wrapper" class="col-12 col-lg-11 col-xl-9 pr-xl-4"> <div id="core-wrapper" class="col-12 col-lg-11 col-xl-9 pr-xl-4">
<div class="post pl-1 pr-1 pl-md-2 pr-md-2"> <div class="post pl-1 pr-1 pl-md-2 pr-md-2">
{% capture _content %} {% capture _content %}
{% if layout.refactor or page.layout == 'page' %} {% if layout.refactor or page.layout == 'page' %}
{% include refactor-content.html content=content %} {% include refactor-content.html content=content lang=lang %}
{% else %} {% else %}
{{ content }} {{ content }}
{% endif %} {% endif %}
@ -20,7 +20,7 @@ layout: default
{% if page.layout == 'page' or page.collection == 'tabs' %} {% if page.layout == 'page' or page.collection == 'tabs' %}
{% assign tab_key = page.title | downcase %} {% assign tab_key = page.title | downcase %}
{% assign title = site.data.locales[site.lang].tabs[tab_key] | default: page.title %} {% assign title = site.data.locales[lang].tabs[tab_key] | default: page.title %}
<h1 class="dynamic-title"> <h1 class="dynamic-title">
{{ title }} {{ title }}
</h1> </h1>
@ -30,24 +30,22 @@ layout: default
{% else %} {% else %}
{{ _content }} {{ _content }}
{% endif %} {% endif %}
</div> </div>
</div> <!-- #core-wrapper --> </div>
<!-- #core-wrapper -->
<!-- panel --> <!-- panel -->
<div id="panel-wrapper" class="col-xl-3 pl-2 text-muted"> <div id="panel-wrapper" class="col-xl-3 pl-2 text-muted">
<div class="access"> <div class="access">
{% include update-list.html %} {% include update-list.html lang=lang %}
{% include trending-tags.html %} {% include trending-tags.html lang=lang %}
</div> </div>
{% for _include in layout.panel_includes %} {% for _include in layout.panel_includes %}
{% assign _include_path = _include | append: '.html' %} {% assign _include_path = _include | append: '.html' %}
{% include {{ _include_path }} %} {% include {{ _include_path }} lang=lang %}
{% endfor %} {% endfor %}
</div> </div>
</div> </div>
<!-- tail --> <!-- tail -->
@ -56,7 +54,7 @@ layout: default
<div id="tail-wrapper" class="col-12 col-lg-11 col-xl-9 pl-3 pr-3 pr-xl-4 mt-5"> <div id="tail-wrapper" class="col-12 col-lg-11 col-xl-9 pl-3 pr-3 pr-xl-4 mt-5">
{% for _include in layout.tail_includes %} {% for _include in layout.tail_includes %}
{% assign _include_path = _include | append: '.html' %} {% assign _include_path = _include | append: '.html' %}
{% include {{ _include_path }} %} {% include {{ _include_path }} lang=lang %}
{% endfor %} {% endfor %}
</div> </div>
</div> </div>

View file

@ -9,20 +9,22 @@ tail_includes:
- comments - comments
--- ---
{% include lang.html %}
<h1 data-toc-skip>{{ page.title }}</h1> <h1 data-toc-skip>{{ page.title }}</h1>
<div class="post-meta text-muted"> <div class="post-meta text-muted">
<!-- published date --> <!-- published date -->
<span> <span>
{{ site.data.locales[site.lang].post.posted }} {{ site.data.locales[lang].post.posted }}
{% include datetime.html date=page.date tooltip=true %} {% include datetime.html date=page.date tooltip=true lang=lang %}
</span> </span>
<!-- lastmod date --> <!-- lastmod date -->
{% if page.last_modified_at %} {% if page.last_modified_at %}
<span> <span>
{{ site.data.locales[site.lang].post.updated }} {{ site.data.locales[lang].post.updated }}
{% include datetime.html date=page.last_modified_at tooltip=true %} {% include datetime.html date=page.last_modified_at tooltip=true lang=lang %}
</span> </span>
{% endif %} {% endif %}
@ -54,7 +56,7 @@ tail_includes:
{% assign authors = page.authors %} {% assign authors = page.authors %}
{% endif %} {% endif %}
{{ site.data.locales[site.lang].post.written_by }} {{ site.data.locales[lang].post.written_by }}
<em> <em>
{% if authors %} {% if authors %}
@ -75,12 +77,12 @@ tail_includes:
<em id="pv" class="pageviews"> <em id="pv" class="pageviews">
<i class="fas fa-spinner fa-spin fa-fw"></i> <i class="fas fa-spinner fa-spin fa-fw"></i>
</em> </em>
{{ site.data.locales[site.lang].post.pageview_measure }} {{ site.data.locales[lang].post.pageview_measure }}
</span> </span>
{% endif %} {% endif %}
<!-- read time --> <!-- read time -->
{% include read-time.html content=content prompt=true %} {% include read-time.html content=content prompt=true lang=lang %}
</div> </div>
</div> <!-- .d-flex --> </div> <!-- .d-flex -->
@ -121,20 +123,20 @@ tail_includes:
d-flex justify-content-between align-items-center mt-3 pt-5 pb-2"> d-flex justify-content-between align-items-center mt-3 pt-5 pb-2">
<div class="license-wrapper"> <div class="license-wrapper">
{% if site.data.locales[site.lang].copyright.license.template %} {% if site.data.locales[lang].copyright.license.template %}
{% capture _replacement %} {% capture _replacement %}
<a href="{{ site.data.locales[site.lang].copyright.license.link }}"> <a href="{{ site.data.locales[lang].copyright.license.link }}">
{{ site.data.locales[site.lang].copyright.license.name }} {{ site.data.locales[lang].copyright.license.name }}
</a> </a>
{% endcapture %} {% endcapture %}
{{ site.data.locales[site.lang].copyright.license.template | replace: ':LICENSE_NAME', _replacement }} {{ site.data.locales[lang].copyright.license.template | replace: ':LICENSE_NAME', _replacement }}
{% endif %} {% endif %}
</div> </div>
{% include post-sharing.html %} {% include post-sharing.html lang=lang %}
</div><!-- .post-tail-bottom --> </div><!-- .post-tail-bottom -->

View file

@ -3,6 +3,8 @@ layout: page
# The layout for Tag page # The layout for Tag page
--- ---
{% include lang.html %}
<div id="page-tag"> <div id="page-tag">
<h1 class="pl-lg-2"> <h1 class="pl-lg-2">
<i class="fa fa-tag fa-fw text-muted"></i> <i class="fa fa-tag fa-fw text-muted"></i>
@ -14,7 +16,7 @@ layout: page
<li class="d-flex justify-content-between pl-md-3 pr-md-3"> <li class="d-flex justify-content-between pl-md-3 pr-md-3">
<a href="{{ post.url | relative_url }}">{{ post.title }}</a> <a href="{{ post.url | relative_url }}">{{ post.title }}</a>
<span class="dash flex-grow-1"></span> <span class="dash flex-grow-1"></span>
{% include datetime.html date=post.date wrap='span' class='text-muted small' %} {% include datetime.html date=post.date wrap='span' class='text-muted small' lang=lang %}
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>

View file

@ -9,6 +9,8 @@ redirect_from:
- /posts/ - /posts/
--- ---
{% include lang.html %}
<div class="lead"> <div class="lead">
<p>{{site.data.locales[site.lang].not_found.statment }}</p> <p>{{ site.data.locales[lang].not_found.statment }}</p>
</div> </div>