Skip to content

Commit

Permalink
Fix the title bug again
Browse files Browse the repository at this point in the history
根据 Simpleyyt 意见,重新修改引起标题错误相关文件:
1. _includes\_blocks\title.html 中使用 __.title.xxx 引用国际化内容;
2. _includes\_helper\open_graph.html 中 title 变量修改为 og_title;
3. _includes\_helper\toc.html 中 title 变量修改为 toc_title;
4. 为使国际化在标题中生效, categories/index.md tags/index.md about/index.md 删除了头中的 title,并修改 _includes\_partials\page-header.html,以便在 post-header 下显示标题;
5. 修改所有国际化文件,在 title 下添加   archives、 categories、tags 和 about  四个变量。
  • Loading branch information
izhizheng committed Jan 22, 2018
1 parent 5cfed2a commit 253fc6e
Show file tree
Hide file tree
Showing 18 changed files with 83 additions and 16 deletions.
4 changes: 4 additions & 0 deletions _data/languages/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ title:
archive: Archiv
category: Kategorie
tag: Tag
archives: Archiv
categories: Kategorien
tags: Tags
about: Über

author: Author

Expand Down
4 changes: 4 additions & 0 deletions _data/languages/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ title:
category: Category
tag: Tag
schedule: Schedule
archives: Archives
categories: Categories
tags: Tags
about: About

author: Author

Expand Down
4 changes: 4 additions & 0 deletions _data/languages/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ title:
category: Category
tag: Tag
schedule: Schedule
archives: Archives
categories: Categories
tags: Tags
about: About

author: Author

Expand Down
4 changes: 4 additions & 0 deletions _data/languages/fr-FR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ title:
archive: Archive
category: Catégorie
tag: Tag
archives: Archives
categories: Categories
tags: Tags
about: A propos

author: Author

Expand Down
4 changes: 4 additions & 0 deletions _data/languages/id.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ title:
archive: Arsip
category: Kategori
tag: Tag
archives: Arsip
categories: Kategori
tags: Tags
about: Tentang

author: Penulis

Expand Down
4 changes: 4 additions & 0 deletions _data/languages/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ title:
archive: アーカイブ
category: カテゴリ
tag: タグ
archives: アーカイブ
categories: カテゴリ
tags: タグ
about: About

author: Author

Expand Down
4 changes: 4 additions & 0 deletions _data/languages/ko.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ title:
archive: 아카이브
category: 카테고리
tag: 태그
archives: 아카이브
categories: 카테고리
tags: 태그
about: About

author: 작성자

Expand Down
4 changes: 4 additions & 0 deletions _data/languages/pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ title:
archive: Arquivo
category: Categoria
tag: Tag
archives: Arquivos
categories: Categorias
tags: Tags
about: Sobre

author: Autor

Expand Down
4 changes: 4 additions & 0 deletions _data/languages/pt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ title:
archive: Arquivo
category: Categoria
tag: Tag
archives: Arquivos
categories: Categorias
tags: Tags
about: Sobre

author: Author

Expand Down
4 changes: 4 additions & 0 deletions _data/languages/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ title:
category: Категория
tag: Тэг
schedule: Календарь
archives: Архив
categories: Категории
tags: Тэги
about: О сайте

author: Автор

Expand Down
4 changes: 4 additions & 0 deletions _data/languages/zh-Hans.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ title:
category: 分类
tag: 标签
schedule: 日程表
archives: 归档
categories: 分类
tags: 标签
about: 关于

author: 博主

Expand Down
4 changes: 4 additions & 0 deletions _data/languages/zh-hk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ title:
category: 分類
tag: 標籤
schedule: 日程表
archives: 歸檔
categories: 分類
tags: 標籤
about: 關於

author: 博主

Expand Down
4 changes: 4 additions & 0 deletions _data/languages/zh-tw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ title:
category: 分類
tag: 標籤
schedule: 日程表
archives: 歸檔
categories: 分類
tags: 標籤
about: 關於

author: 博主

Expand Down
10 changes: 5 additions & 5 deletions _includes/_blocks/title.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
{% capture title %}
{% assign page_title_suffix = ' | ' | append: site.title %}
{% if page.type == "categories" and page.title == nil %}
{{ __.menu.categories | append: page_title_suffix }}
{{ __.title.categories | append: page_title_suffix }}
{% elsif page.type == "tags" and page.title == nil %}
{{ __.menu.tags | append: page_title_suffix }}
{{ __.title.tags | append: page_title_suffix }}
{% elsif page.type == "about" and page.title == nil %}
{{ __.menu.about | append: page_title_suffix }}
{{ __.title.about | append: page_title_suffix }}
{% else %}
{{ page.title | append: page_title_suffix }}
{% endif %}
{% endcapture %}
{% when 'archive' %}
{% capture title %}{{ __.menu.archives }} | {{ site.title }}{% endcapture %}
{% capture title %}{{ __.title.archives }} | {{ site.title }}{% endcapture %}
{% when 'category' %}
{% capture title %}{{ __.title.category }} | {{ site.title }}{% endcapture %}
{% when 'tag' %}
Expand All @@ -26,4 +26,4 @@
{% capture title %}{{ __.title.schedule }} | {{ site.title }}{% endcapture %}
{% endcase %}

{% assign full_title = title | strip_newlines %}
{% assign title = title | strip_newlines %}
6 changes: 3 additions & 3 deletions _includes/_helper/open_graph.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{% endif %}

{% assign url = page.url | absolute_url %}
{% assign title = page.title | default: site.title %}
{% assign og_title = page.title | default: site.title %}
{% assign site_name = site.title %}
{% assign language = page.language | default: site.language %}
{% assign updated = page.updated %}
Expand Down Expand Up @@ -54,7 +54,7 @@
{% endif %}

<meta property="og:type" content="{{ type | xml_escape }}"><!--newline-->
<meta property="og:title" content="{{ title | xml_escape }}"><!--newline-->
<meta property="og:title" content="{{ og_title | xml_escape }}"><!--newline-->
<meta property="og:url" content="{{ url }}"><!--newline-->
<meta property="og:site_name" content="{{ site_name | xml_escape }}"><!--newline-->

Expand All @@ -79,7 +79,7 @@
{% endif %}

<meta name="twitter:card" content="{{ twitter_card | xml_escape }}"><!--newline-->
<meta name="twitter:title" content="{{ title | xml_escape }}"><!--newline-->
<meta name="twitter:title" content="{{ og_title | xml_escape }}"><!--newline-->

{% if description %}
<meta name="twitter:description" content="{{ description }}">
Expand Down
10 changes: 5 additions & 5 deletions _includes/_helper/toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{% endif %}
{% assign str = str_stack | last %}
{% assign level = level_stack | last %}
{% assign title = title_stack | last %}
{% assign toc_title = title_stack | last %}
{% assign id = id_stack | last %}
{% assign num = num_stack | last %}

Expand Down Expand Up @@ -49,7 +49,7 @@
{% assign num_array = num_array | slice: 0, level %}
{% assign num_array = num_array | push: num %}

{% if title and num_array.size != 0 %}
{% if toc_title and num_array.size != 0 %}
<li class="{{ class }}-item {{ class }}-level-{{ level }}">
<a class="{{ class }}-link" href="#{{ id }}">
{% if list_number %}
Expand All @@ -58,7 +58,7 @@
{% assign number = number | strip | remove_first: '.' %}
<span class="{{ class }}-number">{{ number }}</span>
{% endif %}
<span class="{{ class }}-text">{{ title }}</span>
<span class="{{ class }}-text">{{ toc_title }}</span>
</a>
{% endif %}

Expand Down Expand Up @@ -91,14 +91,14 @@
{% assign str = tmp[1] | strip %}

{% assign tmp = tmp[0] | strip | split: '>' %}
{% assign title = tmp | shift | join: '>' | strip_html %}
{% assign toc_title = tmp | shift | join: '>' | strip_html %}

{% assign tmp = tmp[0] | strip | split: 'id=' %}
{% assign id = tmp[1] | strip | replace: '"', '' %}

{% assign str_stack = str_stack | push: str %}
{% assign level_stack = level_stack | push: level %}
{% assign title_stack = title_stack | push: title %}
{% assign title_stack = title_stack | push: toc_title %}
{% assign id_stack = id_stack | push: id %}
{% assign num_stack = num_stack | push: forloop.rindex %}
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion _includes/_layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<html class="{{ html_class | downcase }}" lang="{{ site.language }}">
<head>
{% include _partials/head.html %}
<title>{{ full_title }}</title>
<title>{{ title }}</title>
{% include _third-party/analytics/index.html %}
</head>

Expand Down
19 changes: 17 additions & 2 deletions _includes/_partials/page-header.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
<header class="post-header">

<{% if site.seo %}h2{% else %}h1{% endif %} class="post-title" itemprop="name headline">{{ page.title }}</{% if site.seo %}h2{% else %}h1{% endif %}>
{% case page.layout %}
{% when 'page' %}
{% capture post_title %}
{% if page.type == "categories" and page.title == nil %}
{{ __.title.categories }}
{% elsif page.type == "tags" and page.title == nil %}
{{ __.title.tags }}
{% elsif page.type == "about" and page.title == nil %}
{{ __.title.about }}
{% else %}
{{ page.title }}
{% endif %}
{% endcapture %}
{% when 'schedule' %}
{% capture post_title %}{{ __.title.schedule }}{% endcapture %}
{% endcase %}
<{% if site.seo %}h2{% else %}h1{% endif %} class="post-title" itemprop="name headline">{{ post_title }}</{% if site.seo %}h2{% else %}h1{% endif %}>

{% if page.description %}
<div class="post-meta">
Expand Down

0 comments on commit 253fc6e

Please sign in to comment.