forked from contentful/11ty-contentful-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpages.11ty.js
44 lines (41 loc) · 1.23 KB
/
pages.11ty.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
class Pages {
data() {
return {
pagination: {
data: "contentful-page",
size: 1,
alias: "page",
addAllPagesToCollections: true,
},
permalink: function (data) {
return `${this.slug(data.page.slug)}/`;
},
tags: "page",
layout: "layout.11ty.js",
eleventyComputed: {
title: function (data) {
return data.page.title;
},
},
};
}
async render(data) {
const renderedShortcodes = await Promise.all(
data.page.components.map((component) => {
if (component.sys.contentType.sys.id == "contentBlock") {
return this.contentBlock(component);
} else if (component.sys.contentType.sys.id == "featuretteBlock") {
return this.featuretteBlock(component);
} else if (component.sys.contentType.sys.id == "cardBlock") {
return this.cardBlock(component);
} else if (component.sys.contentType.sys.id == "bannerBlock") {
return this.bannerBlock(component);
} else if (component.sys.contentType.sys.id == "footerBlock") {
return this.footerBlock(component);
}
})
);
return renderedShortcodes.join("");
}
}
module.exports = Pages;