-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
63 lines (49 loc) · 1.45 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const Metaset = require('metaset');
module.exports = function (Doz, app, options) {
const defaultOpts = Object.assign({
title: '',
type: '',
description: '',
url: '',
siteName: '',
locale: '',
image: '',
selfWindow: window
}, options);
function metaTag(opts) {
opts = Object.assign(defaultOpts, opts);
const metaset = new Metaset(opts.selfWindow);
// Title
if (opts.title) {
metaset.setTitle(opts.title);
metaset.setMetaProperty('og:title', opts.title);
}
// Description
if (opts.description) {
metaset.setMetaName('description', opts.description);
metaset.setMetaProperty('og:description', opts.description);
}
// Type
if (opts.type)
metaset.setMetaProperty('og:type', opts.type);
// Url
if (opts.url)
metaset.setMetaProperty('og:url', opts.url);
// Site name
if (opts.siteName)
metaset.setMetaProperty('og:site_name', opts.siteName);
// Locale
if (opts.locale)
metaset.setMetaProperty('og:locale', opts.locale);
// Image
if (opts.image)
metaset.setMetaProperty('og:image', opts.image);
}
// Apply to loading
metaTag();
// Add to global component
Doz.mixin({
metaTag
});
};
module.exports.metaset = new Metaset();