forked from datocms/hugo-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdato.config.js
68 lines (63 loc) · 2.23 KB
/
dato.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
57
58
59
60
61
62
63
64
65
66
67
68
const by = require('sort-by');
const ellipsize = require('ellipsize');
module.exports = (dato, root) => {
root.directory('data/', dir => {
dir.createDataFile('home.toml', 'toml', {
sitename: dato.homepage.siteName,
tagline: dato.homepage.tagLine,
description: dato.homepage.description
});
});
root.directory('content/season', dir => {
dato.seasons.forEach(season => {
dir.createPost(
`${season.slug()}.md`, 'yaml', {
frontmatter: {
title: season.name,
imageurl: season.image.url({ w: 400}),
thumbnailurl: season.image.url({ h: 300 }),
bgurl: season.image.url({ w: 5}),
weight: season.position,
excerpt: ellipsize(season.overview, 150),
},
content: season.overview,
}
);
});
});
root.directory('content/episode', dir => {
dato.episodes.sort(by('-id')).forEach((episode, i) => {
dir.createPost(`${episode.slug()}.md`, 'toml', {
frontmatter: {
title: episode.title,
episodenumber: episode.episodeNumber,
paletteurl: episode.image && episode.image.url({ auto: 'enhance', palette: 'json' }),
imageurl: episode.image && episode.image.url(),
thumbnailurl: episode.image && episode.image.url({ w: 500, h: 280, fit: 'crop', auto: 'enhance', fm: 'jpg' }),
date: episode.firstAired.toMap(),
weight: i,
rating: episode.rating,
director: episode.director,
category: episode.season.name,
},
content: episode.description,
});
});
});
root.directory('content/character', dir => {
dato.characters.forEach(character => {
dir.createPost(`${character.slug()}.md`, 'toml', {
frontmatter: {
title: character.name,
actorname: character.actorName,
episodes: character.episode,
weight: character.position,
thumbnailurl: character.image.url({ fit: 'crop', crop: 'faces', w: 200, h: 200 }),
imageurl: character.image.url({ w: 500, fm: 'jpg' }),
},
content: character.description,
});
});
});
root.addToDataFile('config.toml', 'toml', { title: dato.homepage.siteName });
}