-
Notifications
You must be signed in to change notification settings - Fork 1
/
sponsor-page.11ty.js
135 lines (123 loc) · 3.5 KB
/
sponsor-page.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
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
const displayDescription = (partner) => {
if (!partner.description) {
return "";
}
return `<div class="talk"><p>${
partner.description?.replaceAll('"', "")?.trim() ?? ""
}</p></div>`;
};
const displaySocialMedias = (partner) => {
return `
<div class="talk">
<h3>Sur Internet</h3>
<ul>
${
partner.twitterAccount
? `<li>
<strong class="stressed">Sur Twitter: </strong>
<a target="_blank" href="${
partner.twitterAccount
}">${partner.twitterAccount?.replace(
"https://twitter.com/",
""
)}</a>
</li>`
: ""
}
${
partner.linkedinAccount
? `<li>
<strong class="stressed">Sur LinkedIn: </strong>
<a target="_blank" href="${
partner.linkedinAccount
}">${decodeURI(partner.linkedinAccount)
?.replace("https://www.linkedin.com/in/", "")
?.replace("https://www.linkedin.com/company/", "")
.replace("/", "")}</a>
</li>`
: ""
}
${
partner.siteUrl
? `<li>
<strong class="stressed">Site Web: </strong>
<a target="_blank" href="${partner.siteUrl}">${partner.siteUrl}</a>
</li>`
: ""
}
</ul>
</div>
`;
};
const displayWLDOffers = (partner) => {
return partner.jobs?.length > 0
? `<div class="talk"><h3>Offres sur WeLoveDevs </h3><p>
<ul>${partner.jobs
.map((job) => `<li><a href="${job.url}">${job.title}</a></li>`)
.join("")}</ul>
</p></div>`
: "";
};
export default class SponsorPage {
data() {
return {
layout: "layout.html",
currSection: "partners",
pagination: {
data: "collections.partners",
size: 1,
alias: "partner",
resolve: "values",
before: function (paginationData) {
return paginationData.reduce((acc, data) => [...acc, ...data], []);
},
},
permalink: (ctx) => {
return `partner-${ctx.partner.id}/`;
},
eleventyComputed: {
title: (ctx) => {
return ctx.partner.name;
},
ogUrl: (ctx) => {
return "https://devlille.fr/partner-" + ctx.partner.id;
},
ogTitle: (ctx) => {
return ctx.partner.name;
},
ogDescription: (ctx) => {
return ctx.partner.description?.replaceAll('"', "")?.trim();
},
ogImage: (ctx) => {
return `https://devlille.fr/img/${ctx.partner.logoName}.${ctx.partner.ext}`;
},
},
};
}
render({ partner }) {
if (!partner) {
return null;
}
return `
<div class="page-body list">
<h2>${partner.name}</h2>
<div class="speaker-sheet">
<div class="speaker">
${displayDescription(partner)}
${displaySocialMedias(partner)}
${displayWLDOffers(partner)}
</div>
<div class="speaker-data-block">
<div class="speaker-data">
<p class="sponsor"><a href="${
partner.siteUrl
}"><img loading="lazy" src="/img/${partner.logoName}.${
partner.ext
}"" alt="Logo de ${partner.name}" /></a></p>
</div>
</div>
</div>
</div>
`;
}
}