-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetchContentful.js
65 lines (58 loc) · 2.11 KB
/
fetchContentful.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
const space = process.env.NEXT_PUBLIC_CONTENTFUL_SPACE_ID;
const accessToken = process.env.NEXT_PUBLIC_CONTENTFUL_ACCESS_TOKEN;
const client = require("contentful").createClient({
space: space,
accessToken: accessToken,
});
export async function fetchHomePageContent() {
const entry = await client.getEntry("1odRcAB6FhDDT3TjiJ8HmP");
return {
tagLine: entry.fields.tagLine,
aboutMe: entry.fields.aboutMe,
CTA: entry.fields.cta,
portfolioPictureURL: entry.fields.portfolioPicture.fields.file.url,
src: entry.fields.portfolioPicture.fields.file.url,
id: entry.sys.id,
};
}
export async function fetchPortfolioPageContent() {
const entry = await client.getEntry("69lvZEULtT6EtHQM9nN3Ok");
return {
src: entry.fields.portfolioPicture.fields.file.url,
alt: entry.fields.name,
title: entry.fields.title,
description: entry.fields.description,
id: entry.sys.id,
};
}
export async function fetchProjects() {
const entries = await client.getEntries({ content_type: "project" });
console.log("ENTRY", entries.fields);
const projects = entries.items.map((project) => {
return {
title: project.fields.title,
projectScreenshot: project.fields.projectScreenshot.fields.file.url,
id: project.sys.id,
description: project.fields.description,
link: project.fields.visitWebsite,
};
});
return projects;
}
export async function fetchProjectById(id) {
const entry = await client.getEntry(id);
return {
title: entry.fields.title,
projectBackground: entry.fields.projectBackground,
technologies: entry.fields.technologies,
heroProjectScreenshot: entry.fields.heroProjectScreenshot.fields.file.url,
description: entry.fields.description,
previewImg: entry.fields.staticPreview[0].fields.file.url,
previewImage: entry.fields.staticPreview[1].fields.file.url,
link: entry.fields.visitWebsite,
prevProjectTitle: entry.fields.previousProject.fields.title,
prevProjectId: entry.fields.previousProject.sys.id,
nextProjectTitle: entry.fields.nextProject.fields.title,
nextProjectId: entry.fields.nextProject.sys.id,
};
}