-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
35 lines (30 loc) · 945 Bytes
/
index.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
35
/* global hexo */
'use strict';
hexo.config.opengraph_image = Object.assign({
enable: true,
main_color: '#fff',
secondary_color: "#000",
font_color: "#000",
title_font: "Bold 70pt Arial",
date_font: "Regular 30pt Arial",
date_style: "YYYY/MM/DD",
}, hexo.config.opengraph_image);
const config = hexo.config.opengraph_image;
const ogimage = require('./lib/generator');
if (!config.enable) {
return;
}
hexo.extend.generator.register('opengraph_image', locals => {
return ogimage.call(hexo, locals);
});
hexo.extend.helper.register('opengraph_image', function(){
if (this.is_post() ) {
let url_path = "";
if (this.page.thumbnail) {
url_path = this.full_url_for(this.page.thumbnail);
} else {
url_path = this.full_url_for(this.path).replace(/index\.html$/, "") +'thumbnail.png';
}
return '<meta property="og:image" content="' + url_path + '" />';
}
});