-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0673d02
commit 62e19a5
Showing
16 changed files
with
129 additions
and
23 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { getProjects } from "@/codeforafrica/lib/data/utils/projects"; | ||
|
||
async function ourWork(block, api, context) { | ||
const { query } = context; | ||
const data = await getProjects(api, query); | ||
|
||
return { | ||
...block, | ||
...data, | ||
slug: block.blockType, | ||
}; | ||
} | ||
|
||
export default ourWork; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const orQueryBuilder = (fields, search) => { | ||
if (!search) { | ||
return []; | ||
} | ||
return fields.map((field) => ({ [field]: { like: search } })); | ||
}; | ||
|
||
export async function getProjects(api, params) { | ||
const { page: queryPage = 1, q } = params; | ||
const fields = ["name", "title", "tags", "tagLine"]; | ||
const orQuery = orQueryBuilder(fields, q); | ||
const options = { | ||
limit: 6, | ||
page: queryPage, | ||
where: { | ||
or: orQuery, | ||
}, | ||
}; | ||
const { | ||
docs: results, | ||
totalPages, | ||
page, | ||
} = await api.getCollection("projects", options); | ||
|
||
return { | ||
results, | ||
pagination: { | ||
count: totalPages, | ||
page, | ||
}, | ||
}; | ||
} | ||
|
||
export default undefined; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { getProjects } from "@/codeforafrica/lib/data/utils/projects"; | ||
import api from "@/codeforafrica/lib/payload"; | ||
|
||
export default async function handler(req, res) { | ||
try { | ||
const data = await getProjects(api, req.query); | ||
return res.json(data); | ||
} catch (error) { | ||
return res.status(500).json(error); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const OurWork = { | ||
slug: "our-work", | ||
imageURL: "/images/cms/blocks/projects.png", | ||
imageAltText: "Our Work", | ||
labels: { | ||
singular: { | ||
en: "Our Work", | ||
}, | ||
plural: { | ||
en: "Our Work", | ||
}, | ||
}, | ||
fields: [ | ||
{ | ||
name: "title", | ||
label: { | ||
en: "Title", | ||
}, | ||
type: "text", | ||
}, | ||
], | ||
}; | ||
|
||
export default OurWork; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters