-
Notifications
You must be signed in to change notification settings - Fork 0
/
dato.config.js
70 lines (65 loc) · 2.42 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
69
// Arguments that will receive the mapping function:
//
// * dato: lets you easily access any content stored in your DatoCMS
// administrative area;
//
// * root: represents the root of your project, and exposes commands to
// easily create local files/directories;
//
// * i18n: allows to switch the current locale to get back content in
// alternative locales from the first argument.
//
// Read all the details here:
// https://github.com/datocms/js-datocms-client/blob/master/docs/dato-cli.md
module.exports = (dato, root, i18n) => {
// Create a YAML data file to store global data about the site
root.createDataFile('source/_data/settings.yml', 'yaml', {
name: dato.site.globalSeo.siteName,
language: dato.site.locales[0],
intro: dato.home.introText,
copyright: dato.home.copyright,
// iterate over all the `social_profile` item types
socialProfiles: dato.socialProfiles.map(profile => {
return {
type: profile.profileType.toLowerCase().replace(/ +/, '-'),
url: profile.url,
};
}),
faviconMetaTags: dato.site.faviconMetaTags,
seoMetaTags: dato.home.seoMetaTags
});
// Create a markdown file with content coming from the `about_page` item
// type stored in DatoCMS
root.createPost(`source/about/index.md`, 'yaml', {
frontmatter: {
title: dato.aboutPage.title,
subtitle: dato.aboutPage.subtitle,
photo: dato.aboutPage.photo.url({ w: 800, fm: 'jpg', auto: 'compress' }),
layout: 'page',
seoMetaTags: dato.aboutPage.seoMetaTags,
},
content: dato.aboutPage.bio
});
// Create a `_posts` directory (or empty it if already exists)...
root.directory('source/_posts', dir => {
// ...and for each of the works stored online...
dato.works.forEach((work, index) => {
// ...create a markdown file with all the metadata in the frontmatter
dir.createPost(`${work.slug}.md`, 'yaml', {
frontmatter: {
title: work.title,
layout: 'post',
coverImage: work.coverImage.url({ w: 450, fm: 'jpg', auto: 'compress' }),
detailImage: work.coverImage.url({ w: 600, fm: 'jpg', auto: 'compress' }),
position: index,
contentExcerpt: work.excerpt,
seoMetaTags: work.seoMetaTags,
extraImages: work.gallery.map(image =>
image.url({ h: 300, fm: 'jpg', auto: 'compress' })
),
},
content: work.description
});
});
});
};