-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhelpers.js
34 lines (31 loc) · 857 Bytes
/
helpers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'use strict';
hexo.extend.helper.register('generatePageTitle', function(page) {
const config = this.config;
const siteTitle = config.title || '';
const subtitle = config.subtitle || '';
let pageTitle = '';
if (this.is_archive()) {
pageTitle = this.__('page.archive');
} else if (this.is_tag()) {
pageTitle = page.tag;
} else if (this.is_category()) {
pageTitle = page.category;
} else if (this.is_post() || this.is_page()) {
pageTitle = page.title;
}
if (this.is_home()) {
if (siteTitle && subtitle) {
return `${siteTitle} | ${subtitle}`;
} else if (siteTitle) {
return siteTitle;
} else if (subtitle) {
return subtitle;
}
} else {
if (pageTitle) {
return `${pageTitle} | ${siteTitle}`;
} else {
return siteTitle;
}
}
});