-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (38 loc) · 923 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
36
37
38
39
40
const fs = require('fs');
const path = require('path');
module.exports = {
i18n: {
aposFavicon: {
browser: true
}
},
bundle: {
directory: 'modules',
modules: getBundleModuleNames()
},
init(self) {
self.apos.template.append('head', '@apostrophecms/favicon:head');
},
components(self) {
return {
head(req) {
const doc = req.data.global;
const attachment = self.apos.image.first(doc.favicon);
if (!attachment) {
return {};
}
const url = self.apos.attachment.url(attachment, { size: 'one-third' });
return {
url
};
}
};
}
};
function getBundleModuleNames() {
const source = path.join(__dirname, './modules/@apostrophecms');
return fs
.readdirSync(source, { withFileTypes: true })
.filter(dirent => dirent.isDirectory())
.map(dirent => `@apostrophecms/${dirent.name}`);
}