-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.js
56 lines (52 loc) · 1.47 KB
/
config.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
import path from 'path'
/**
* Posts content type translation
* @param {Array} content List of files
* @param {String} contentType Content type name
* @return {Object} The posts content type data object
*/
function posts (content, contentType) {
let output = {}
const allFiles = content.filter(each => each.dir.includes(`/${contentType}`))
const index = allFiles.filter(each => each.base === 'index.md')[0]
index.attr.forEach(each => {
allFiles.forEach(file => {
if (file.name === each) {
output[each] = file
}
})
})
return output
}
/**
* Gallery content type translation
* @param {Array} content List of files
* @param {String} contentType Content type name
* @return {Object} The gallery content type data object
*/
function gallery (content, contentType) {
let output = {}
const allFiles = content.filter(each => each.dir.includes(`/${contentType}`))
const index = allFiles.filter(each => each.base === 'index.md')[0]
index.attr.forEach(each => {
Object.keys(each).forEach(key => {
output[key] = Object.assign({ title: each[key] }, allFiles.filter(file => file.name === key)[0])
})
})
return output
}
/**
* Configuration
* @type {Object}
*/
const config = {
content: path.resolve(__dirname, 'content'),
output: path.resolve(__dirname, 'data.json'),
include: ['.md', '.png'],
exclude: ['README.md'],
contentTypes: [
{ posts },
{ gallery },
]
}
export default config