diff --git a/_includes/datetime.html b/_includes/datetime.html index e659c5a..00aaea4 100644 --- a/_includes/datetime.html +++ b/_includes/datetime.html @@ -4,12 +4,16 @@ --> {% assign wrap_elem = include.wrap | default: 'em' %} -{% assign df_strftime = site.data.locales[site.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_strftime = site.data.locales[include.lang].df.post.strftime | default: '%d/%m/%Y' %} +{% assign df_dayjs = site.data.locales[include.lang].df.post.dayjs | default: 'DD/MM/YYYY' %} -<{{ wrap_elem }} class="{% if include.class %}{{ include.class }}{% endif %}" - data-ts="{{ include.date | date: '%s' }}" - data-df="{{ df_dayjs }}" - {% if include.tooltip %}data-toggle="tooltip" data-placement="bottom"{% endif %}> +<{{ wrap_elem }} + class="{% if include.class %}{{ include.class }}{% endif %}" + data-ts="{{ include.date | date: '%s' }}" + data-df="{{ df_dayjs }}" + {% if include.tooltip %} + data-toggle="tooltip" data-placement="bottom" + {% endif %} +> {{ include.date | date: df_strftime }} diff --git a/_includes/footer.html b/_includes/footer.html index f4b16d9..b8f4ec7 100644 --- a/_includes/footer.html +++ b/_includes/footer.html @@ -5,18 +5,22 @@
diff --git a/_includes/lang.html b/_includes/lang.html new file mode 100644 index 0000000..19558a0 --- /dev/null +++ b/_includes/lang.html @@ -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 %} diff --git a/_includes/post-nav.html b/_includes/post-nav.html index 7a12e69..76bcd59 100644 --- a/_includes/post-nav.html +++ b/_includes/post-nav.html @@ -1,30 +1,37 @@ - +
{% if page.previous.url %} - -

{{ page.previous.title }}

-
+ +

{{ page.previous.title }}

+
{% else %} -
-

-

-
+
+

-

+
{% endif %} {% if page.next.url %} - -

{{ page.next.title }}

-
+ +

{{ page.next.title }}

+
{% else %} -
-

-

-
+
+

-

+
{% endif %} -
diff --git a/_includes/post-sharing.html b/_includes/post-sharing.html index c241ea5..8c4598e 100644 --- a/_includes/post-sharing.html +++ b/_includes/post-sharing.html @@ -1,9 +1,7 @@ - +
- +
diff --git a/_includes/read-time.html b/_includes/read-time.html index 6363da3..6d53357 100644 --- a/_includes/read-time.html +++ b/_includes/read-time.html @@ -1,10 +1,8 @@ - + -{% assign words = include.content | strip_html | number_of_words: "auto" %} +{% assign words = include.content | strip_html | number_of_words: 'auto' %} - + {% assign wpm = 180 %} {% assign min_time = 1 %} @@ -16,15 +14,24 @@ {% endunless %} {% capture read_prompt %} - {{- site.data.locales[site.lang].post.read_time.prompt -}} + {{- site.data.locales[include.lang].post.read_time.prompt -}} {% endcapture %} - - {{- read_time -}}{{" "}}{{- site.data.locales[site.lang].post.read_time.unit -}} + + + {{- read_time -}} + {{ ' ' }} + {{- site.data.locales[include.lang].post.read_time.unit -}} + {%- if include.prompt -%} {%- assign _prompt_words = read_prompt | number_of_words: 'auto' -%} - {%- unless _prompt_words > 1 -%}{{ " " }}{%- endunless -%}{{ read_prompt }} + {%- unless _prompt_words > 1 -%}{{ ' ' }}{%- endunless -%} + {{ read_prompt }} {%- endif -%} diff --git a/_includes/refactor-content.html b/_includes/refactor-content.html index 3a6f943..ea6f139 100644 --- a/_includes/refactor-content.html +++ b/_includes/refactor-content.html @@ -225,7 +225,7 @@ | append: '
' | append: _label | append: '
' | append: '
' %} diff --git a/_includes/related-posts.html b/_includes/related-posts.html index b992c6e..69e9970 100644 --- a/_includes/related-posts.html +++ b/_includes/related-posts.html @@ -1,20 +1,20 @@ - + {% assign TOTAL_SIZE = 3 %} - + {% assign TAG_SCORE = 1 %} - + {% 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 %} {% for i in (0..last_index) %} @@ -42,11 +42,9 @@ {% capture score_item %}{{ score }}{{ SEPARATOR }}{{ i }}{% endcapture %} {% assign score_list = score_list | push: score_item %} {% endif %} - {% endfor %} - -{% assign index_list = "" | split: "" %} +{% assign index_list = '' | split: '' %} {% if score_list.size > 0 %} {% assign score_list = score_list | sort | reverse %} @@ -56,13 +54,13 @@ {% endfor %} {% endif %} - + {% assign less = TOTAL_SIZE | minus: index_list.size %} {% if less > 0 %} {% for i in (0..last_index) %} {% assign post = site.posts[i] %} - {% if post.url != page.url %} + {% if post.url != page.url %} {% capture cur_index %}{{ i }}{% endcapture %} {% unless index_list contains cur_index %} {% assign index_list = index_list | push: cur_index %} @@ -77,27 +75,33 @@ {% if index_list.size > 0 %} + +
+ {% endif %} diff --git a/_includes/search-loader.html b/_includes/search-loader.html index 603ea5b..b14d1e5 100644 --- a/_includes/search-loader.html +++ b/_includes/search-loader.html @@ -14,7 +14,7 @@
{% endcapture %} -{% capture not_found %}

{{ site.data.locales[site.lang].search.no_results }}

{% endcapture %} +{% capture not_found %}

{{ site.data.locales[include.lang].search.no_results }}

{% endcapture %} diff --git a/_includes/sidebar.html b/_includes/sidebar.html index c570597..5dd8fc2 100644 --- a/_includes/sidebar.html +++ b/_includes/sidebar.html @@ -1,6 +1,4 @@ - + + + + + - - + + + + diff --git a/_includes/toc.html b/_includes/toc.html index 0d1967c..d47ea28 100644 --- a/_includes/toc.html +++ b/_includes/toc.html @@ -7,7 +7,7 @@ {% if enable_toc %}
-
{{- site.data.locales[site.lang].panel.toc -}}
+
{{- site.data.locales[include.lang].panel.toc -}}
diff --git a/_includes/topbar.html b/_includes/topbar.html index 51fbf1a..91494db 100644 --- a/_includes/topbar.html +++ b/_includes/topbar.html @@ -1,70 +1,67 @@ - +
+ {% assign paths = page.url | split: '/' %} - {% assign paths = page.url | split: '/' %} + {% if paths.size == 0 or page.layout == 'home' %} + + {{ site.data.locales[include.lang].tabs.home | capitalize }} - {% if paths.size == 0 or page.layout == 'home' %} - - {{ site.data.locales[site.lang].tabs.home | capitalize }} + {% else %} + {% for item in paths %} + {% if forloop.first %} + + + {{ site.data.locales[include.lang].tabs.home | capitalize }} + + - {% else %} + {% elsif forloop.last %} + {% if page.collection == 'tabs' %} + {{ site.data.locales[include.lang].tabs[item] | default: page.title }} + {% else %} + {{ page.title }} + {% endif %} - {% for item in paths %} - - {% if forloop.first %} - - - {{ site.data.locales[site.lang].tabs.home | capitalize }} - - - - {% elsif forloop.last %} - - {% if page.collection == 'tabs' %} - {{ site.data.locales[site.lang].tabs[item] | default: page.title }} - {% else %} - {{ page.title }} + {% elsif page.layout == 'category' or page.layout == 'tag' %} + + + {{ site.data.locales[include.lang].tabs[item] | default: page.title }} + + {% endif %} - - {% elsif page.layout == 'category' or page.layout == 'tag' %} - - - {{ site.data.locales[site.lang].tabs[item] | default: page.title }} - - - {% endif %} - - {% endfor %} - - {% endif %} - - + {% endfor %} + {% endif %} + +
{% 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' %} {%- 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 %} - {{- 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 %}
- + - {{ site.data.locales[site.lang].search.cancel }} + {{ site.data.locales[include.lang].search.cancel }}
-
diff --git a/_includes/trending-tags.html b/_includes/trending-tags.html index d0f58a1..a36108c 100644 --- a/_includes/trending-tags.html +++ b/_includes/trending-tags.html @@ -4,26 +4,26 @@ {% assign MAX = 10 %} -{% assign size_list = "" | split: "" %} -{% assign tag_list = "" | split: "" %} +{% assign size_list = '' | split: '' %} +{% assign tag_list = '' | split: '' %} {% for tag in site.tags %} {% assign size = tag | last | size %} {% assign size_list = size_list | push: size %} - {% assign tag_str = tag | first | append: "::" | append: size %} - {% assign tag_list = tag_list | push: tag_str %} + {% assign tag_str = tag | first | append: '::' | append: size %} + {% assign tag_list = tag_list | push: tag_str %} {% endfor %} {% assign size_list = size_list | sort | reverse %} {% assign tag_list = tag_list | sort_natural %} -{% assign trending_tags = "" | split: "" %} +{% assign trending_tags = '' | split: '' %} {% for size in size_list limit: MAX %} {% for tag_str in tag_list %} - {% assign tag = tag_str | split: "::" %} + {% assign tag = tag_str | split: '::' %} {% assign tag_name = tag | first %} {% assign tag_size = tag | last | plus: 0 %} {% if tag_size == size %} @@ -37,14 +37,12 @@ {% if trending_tags.size > 0 %}
-
{{- site.data.locales[site.lang].panel.trending_tags -}}
+
{{- site.data.locales[include.lang].panel.trending_tags -}}
- - {% for tag_name in trending_tags %} - {% assign url = tag_name | slugify | url_encode | prepend: "/tags/" | append: "/" %} - - {% endfor %} - + {% for tag_name in trending_tags %} + {% assign url = tag_name | slugify | url_encode | prepend: '/tags/' | append: '/' %} + + {% endfor %}
{% endif %} diff --git a/_includes/update-list.html b/_includes/update-list.html index a4edd11..0ee7b70 100644 --- a/_includes/update-list.html +++ b/_includes/update-list.html @@ -4,7 +4,7 @@ {% assign MAX_SIZE = 5 %} -{% assign all_list = "" | split: "" %} +{% assign all_list = '' | split: '' %} {% for post in site.posts %} {% if post.last_modified_at %} @@ -17,24 +17,25 @@ {% 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 %} {% endfor %} {% if update_list.size > 0 %} -
-
{{- site.data.locales[site.lang].panel.lastmod -}}
+
{{- site.data.locales[include.lang].panel.lastmod -}}
    {% 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 url = post.url | relative_url %} -
  • {{ post.title }}
  • +
  • + {{ post.title }} +
  • {% endfor %}
-
- + + {% endif %} diff --git a/_layouts/archives.html b/_layouts/archives.html index f86b417..fd482e5 100644 --- a/_layouts/archives.html +++ b/_layouts/archives.html @@ -3,8 +3,10 @@ layout: page # The Archives of posts. --- -{% assign df_strftime_m = site.data.locales[site.lang].df.archives.strftime | default: '/ %m' %} -{% assign df_dayjs_m = site.data.locales[site.lang].df.archives.dayjs | default: '/ MM' %} +{% include lang.html %} + +{% 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' %}
diff --git a/_layouts/categories.html b/_layouts/categories.html index b207186..a08e4c5 100644 --- a/_layouts/categories.html +++ b/_layouts/categories.html @@ -3,8 +3,10 @@ layout: page # All the Categories of posts --- -{% assign HEAD_PREFIX = "h_" %} -{% assign LIST_PREFIX = "l_" %} +{% include lang.html %} + +{% assign HEAD_PREFIX = 'h_' %} +{% assign LIST_PREFIX = 'l_' %} {% assign group_index = 0 %} @@ -16,7 +18,7 @@ layout: page {% assign first_post = posts_of_category | first %} {% if category_name == first_post.categories[0] %} - {% assign sub_categories = "" | split: "" %} + {% assign sub_categories = '' | split: '' %} {% for post in posts_of_category %} {% assign second_category = post.categories[1] %} @@ -30,89 +32,107 @@ layout: page {% assign sub_categories = sub_categories | sort %} {% assign sub_categories_size = sub_categories | size %} -
- -
- - +
+ +
+ + - {% capture _category_url %}/categories/{{ category_name | slugify | url_encode }}/{% endcapture %} - {{ category_name }} + {% capture _category_url %}/categories/{{ category_name | slugify | url_encode }}/{% endcapture %} + {{ category_name }} - - {% assign top_posts_size = site.categories[category_name] | size %} - - {% if sub_categories_size > 0 %} - {{ sub_categories_size }} - {% if sub_categories_size > 1 %} - {{ site.data.locales[site.lang].categories.category_measure.plural - | default: site.data.locales[site.lang].categories.category_measure }} - {% else %} - {{ site.data.locales[site.lang].categories.category_measure.singular - | default: site.data.locales[site.lang].categories.category_measure }} - {% endif %}, - {% endif %} - - {{ top_posts_size }} - - {% if top_posts_size > 1 %} - {{ site.data.locales[site.lang].categories.post_measure.plural - | default: site.data.locales[site.lang].categories.post_measure }} - {% else %} - {{ site.data.locales[site.lang].categories.post_measure.singular - | default: site.data.locales[site.lang].categories.post_measure }} - {% endif %} - - - - - {% if sub_categories_size > 0%} - - - - {% else %} - - - - {% endif %} - -
- - - {% if sub_categories_size > 0 %} -
-
    - {% for sub_category in sub_categories %} -
  • - - - {% capture _sub_ctg_url %}/categories/{{ sub_category | slugify | url_encode }}/{% endcapture %} - {{ sub_category }} - - {% assign posts_size = site.categories[sub_category] | size %} + + {% assign top_posts_size = site.categories[category_name] | size %} - {{ posts_size }} + {% if sub_categories_size > 0 %} + {{ sub_categories_size }} + {% if sub_categories_size > 1 %} + {{ + site.data.locales[lang].categories.category_measure.plural + | default: site.data.locales[lang].categories.category_measure + }} + {% else %} + {{ + site.data.locales[lang].categories.category_measure.singular + | default: site.data.locales[lang].categories.category_measure + }} + {% endif -%} + , + {% endif %} - {% if posts_size > 1 %} - {{ site.data.locales[site.lang].categories.post_measure.plural - | default: site.data.locales[site.lang].categories.post_measure }} + {{ top_posts_size }} + + {% if top_posts_size > 1 %} + {{ + site.data.locales[lang].categories.post_measure.plural + | default: site.data.locales[lang].categories.post_measure + }} {% 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 %} -
  • - {% endfor %} -
-
- {% endif %} + -
+ + {% if sub_categories_size > 0 %} + + + + {% else %} + + + + {% endif %} +
+ + + + {% if sub_categories_size > 0 %} +
+
    + {% for sub_category in sub_categories %} +
  • + + + {% capture _sub_ctg_url %}/categories/{{ sub_category | slugify | url_encode }}/{% endcapture %} + {{ sub_category }} + + {% assign posts_size = site.categories[sub_category] | size %} + + {{ posts_size }} + + {% if posts_size > 1 %} + {{ + site.data.locales[lang].categories.post_measure.plural + | default: site.data.locales[lang].categories.post_measure + }} + {% else %} + {{ + site.data.locales[lang].categories.post_measure.singular + | default: site.data.locales[lang].categories.post_measure + }} + {% endif %} + +
  • + {% endfor %} +
+
+ {% endif %} +
+ {% assign group_index = group_index | plus: 1 %} - {% endif %} {% endfor %} diff --git a/_layouts/category.html b/_layouts/category.html index 07129bb..b926637 100644 --- a/_layouts/category.html +++ b/_layouts/category.html @@ -3,6 +3,8 @@ layout: page # The Category layout --- +{% include lang.html %} +

@@ -12,11 +14,11 @@ layout: page
    {% for post in page.posts %} -
  • - {{ post.title }} - - {% include datetime.html date=post.date wrap='span' class='text-muted small' %} -
  • +
  • + {{ post.title }} + + {% include datetime.html date=post.date wrap='span' class='text-muted small' lang=lang %} +
  • {% endfor %}

diff --git a/_layouts/default.html b/_layouts/default.html index a98c230..3705831 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -3,10 +3,12 @@ layout: compress # Default layout --- - + {% include assets-origin.html %} +{% include lang.html %} + {% capture prefer_mode %} {% if site.theme_mode %} data-mode="{{ site.theme_mode }}" @@ -14,26 +16,24 @@ layout: compress {% endcapture %} - - + {% include head.html %} + {% include sidebar.html lang=lang %} - {% include sidebar.html %} - - {% include topbar.html %} + {% include topbar.html lang=lang %}
{{ content }}
- {% include search-results.html %} + {% include search-results.html lang=lang %} +
+ -
- - {% include footer.html %} + {% include footer.html lang=lang %} {% if page.mermaid %} {% include mermaid.html %} @@ -46,17 +46,24 @@ layout: compress {% if site.pwa.enabled %} - diff --git a/_layouts/tag.html b/_layouts/tag.html index 5fd528f..8dbd65b 100644 --- a/_layouts/tag.html +++ b/_layouts/tag.html @@ -3,6 +3,8 @@ layout: page # The layout for Tag page --- +{% include lang.html %} +

@@ -11,11 +13,11 @@ layout: page

    {% for post in page.posts %} -
  • - {{ post.title }} - - {% include datetime.html date=post.date wrap='span' class='text-muted small' %} -
  • +
  • + {{ post.title }} + + {% include datetime.html date=post.date wrap='span' class='text-muted small' lang=lang %} +
  • {% endfor %}
diff --git a/assets/404.html b/assets/404.html index 4490ea5..0337bac 100644 --- a/assets/404.html +++ b/assets/404.html @@ -9,6 +9,8 @@ redirect_from: - /posts/ --- +{% include lang.html %} +
-

{{site.data.locales[site.lang].not_found.statment }}

+

{{ site.data.locales[lang].not_found.statment }}