-
Notifications
You must be signed in to change notification settings - Fork 34
/
buildContent.ts
47 lines (39 loc) · 1.11 KB
/
buildContent.ts
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
import {readFileSync, writeFileSync} from 'fs';
import {
generateI18NResources,
getContentByType,
mergeDeepAll,
} from './src/utils/utils';
const categories = generateI18NResources(
getContentByType('categories'),
'categories',
);
const collections = generateI18NResources(
getContentByType('collections'),
'collections',
);
const exercises = generateI18NResources(
getContentByType('exercises'),
'exercises',
);
const ui = generateI18NResources(getContentByType('ui'));
const email = generateI18NResources(getContentByType('email'), 'email');
const tags = generateI18NResources(getContentByType('tags'), 'tags');
const i18n = mergeDeepAll(categories, collections, exercises, tags, ui, email);
const {contributors} = JSON.parse(
readFileSync('../.all-contributorsrc', {encoding: 'utf8'}),
);
const featured = JSON.parse(
readFileSync('./src/featured/content.json', {encoding: 'utf8'}),
);
const data = JSON.stringify({
i18n,
featured,
contributors,
});
if (process.argv.length > 2) {
writeFileSync(process.argv[2], data);
} else {
process.stdout.write(data);
}
console.log('Content built!');