Skip to content

Commit

Permalink
fix: Solved the problem that the same title in different pages
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyib committed Sep 16, 2019
1 parent 891b1b7 commit 57ef4c3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
2 changes: 1 addition & 1 deletion layout/_layout.pug
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
doctype html
html(lang=config.language)
head
!= partial('./_partials/head/head.pug', null, { cache: theme.cache })
include ./_partials/head/head.pug
body
div#container.container
header#header.header
Expand Down
41 changes: 25 additions & 16 deletions layout/_partials/head/head.pug
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
-
var title = __('title') !== 'title' ? __('title') : config.title
var subtitle = __('subtitle') !== 'subtitle' ? __('subtitle') : config.subtitle
var author = __('author') !== 'author' ? __('author') : config.author
var description = __('description') !== 'description' ? __('description') : config.description
var keywords = config.author + ', ' + config.title
var title_suffix = ' | ' + title
var title = __('title') !== 'title' ? __('title') : config.title;
var subtitle = __('subtitle') !== 'subtitle' ? __('subtitle') : config.subtitle;
var author = __('author') !== 'author' ? __('author') : config.author;
var description = __('description') !== 'description' ? __('description') : config.description;
var keywords = config.author + ', ' + config.title;
var title_suffix = ' | ' + title;
if (is_home()) title = title + (theme.index_subtitle ? ' | ' + subtitle : '')
else if (is_archive()) title = __('title.archive') + title_suffix
else if (is_category()) title = __('title.category') + ': ' + page.category + title_suffix
else if (is_tag()) title = __('title.tag') + ': ' + page.tag + title_suffix
else if (is_post()) title = page.title + title_suffix
else if (is_page())
if (page.type === 'tags') title = __('title.tag') + title_suffix
else if (page.type === 'categories') title = __('title.category') + title_suffix
else title = page.title + title_suffix
else title = page.title + title_suffix
if (is_home()) {
title = title + ((theme.index_subtitle && subtitle) ? (' | ' + subtitle) : '');
} else if (is_archive()) {
title = __('title.archive') + title_suffix;
} else if (is_category()) {
title = __('title.category') + ': ' + page.category + title_suffix;
} else if (is_tag()) {
title = __('title.tag') + ': ' + page.tag + title_suffix;
} else if (is_post()) {
title = page.title + title_suffix;
} else {
if (page.type === 'tags') {
title = __('title.tag') + title_suffix;
} else if (page.type === 'categories') {
title = __('title.category') + title_suffix;
} else {
title = page.title + title_suffix;
}
}
meta(charset="UTF-8")
meta(http-equiv="X-UA-Compatible" content="IE=edge")
Expand Down

0 comments on commit 57ef4c3

Please sign in to comment.