-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin.js
47 lines (40 loc) · 1.13 KB
/
plugin.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
/**
* Main we-plugin-page file
*/
const path = require('path'),
metatagContentFindAll = require('./lib/metatags/metatagContentFindAll.js'),
metatagContentFindOne = require('./lib/metatags/metatagContentFindOne.js');
module.exports = function loadPagePlugin(projectPath, Plugin) {
const plugin = new Plugin(__dirname);
plugin.setConfigs({
permissions: {
'access_contents_unpublished': {
'title': 'Access unpublished contents'
}
}
});
plugin.setResource({
name: 'content',
findAll: {
metatagHandler: 'contentFindAll',
search: {
published: {
parser: 'equalBoolean',
target: {
type: 'field',
field: 'published'
}
}
}
},
findOne: { metatagHandler: 'contentFindOne' }
});
plugin.setMetatagHandlers = function setMetatagHandlers(we) {
if (we.router.metatag) {
we.router.metatag.add('contentFindOne', metatagContentFindOne);
we.router.metatag.add('contentFindAll', metatagContentFindAll);
}
}
plugin.events.on('we:after:load:plugins', plugin.setMetatagHandlers);
return plugin;
};