Skip to content

Commit b1c9a2b

Browse files
authored
Merge pull request #1400 from CodeForAfrica/chore/fix-research-page-setting
feat: enhance ReportFilters and Reports components with new properties
2 parents 0ef2f39 + dc9c26c commit b1c9a2b

File tree

8 files changed

+46
-8
lines changed

8 files changed

+46
-8
lines changed

apps/trustlab/next.config.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ const nextConfig = {
5858
"@commons-ui/next",
5959
"@commons-ui/payload",
6060
],
61+
async rewrites() {
62+
return [
63+
{
64+
source: "/robots.txt",
65+
destination: "/api/v1/robots",
66+
},
67+
];
68+
},
6169
};
6270

6371
export default withPayload(

apps/trustlab/src/app/robots.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

apps/trustlab/src/components/ReportFilters/ReportFilters.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,13 @@ const ReportFilters = React.forwardRef(function ReportFilters(
219219
alignItems="center"
220220
justifyContent="space-between"
221221
>
222-
<Box display="flex" flexWrap="wrap" gap={2} flex={1}>
222+
<Box
223+
display="flex"
224+
alignItems="center"
225+
flexWrap="wrap"
226+
gap={2}
227+
flex={1}
228+
>
223229
{selectedYears.map((y) => (
224230
<Chip
225231
key={`year-${y}`}
@@ -292,7 +298,7 @@ const ReportFilters = React.forwardRef(function ReportFilters(
292298
}}
293299
component={CloseIcon}
294300
/>
295-
{clearFiltersLabel || "Clear Filters"}
301+
{clearFiltersLabel || "Clear Filter(s)"}
296302
</Button>
297303
)}
298304
</Box>

apps/trustlab/src/components/ReportFilters/ReportFilters.snap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ exports[`ReportFilters renders unchanged 1`] = `
9696
class="MuiStack-root css-1x34icn-MuiStack-root"
9797
>
9898
<div
99-
class="MuiBox-root css-3772j1"
99+
class="MuiBox-root css-1sl536g"
100100
/>
101101
</div>
102102
</div>

apps/trustlab/src/lib/data/local/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { getPageProps, getPagePaths } from "@/trustlab/lib/data/common";
2-
import { parseRobotsTxt } from "@/trustlab/lib/data/common/seo";
32
import api from "@/trustlab/lib/payload";
43

54
export async function getPageStaticPaths() {
@@ -19,7 +18,7 @@ export async function getPageStaticProps(context) {
1918

2019
export async function getRobotsTxt() {
2120
const siteSettings = await api.findGlobal("site-settings");
22-
return parseRobotsTxt(siteSettings?.robotsTxt);
21+
return siteSettings?.robotsTxt;
2322
}
2423

2524
export default undefined;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { getRobotsTxt } from "@/trustlab/lib/data";
2+
3+
export default async function handler(_req, res) {
4+
const robotsTxt = await getRobotsTxt();
5+
res.setHeader("Content-Type", "text/plain; charset=utf-8");
6+
res.send(robotsTxt);
7+
}

apps/trustlab/src/payload/collections/Reports.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,25 @@ const Reports = {
5353
position: "sidebar",
5454
},
5555
},
56+
image({
57+
overrides: {
58+
name: "pageHeaderImage",
59+
label: "Page Header Image",
60+
description: "Image displayed at the top of the report page",
61+
admin: {
62+
position: "sidebar",
63+
},
64+
},
65+
}),
66+
richText({
67+
name: "pageHeaderDescription",
68+
label: "Page Header Description",
69+
description: "Rich text content displayed below the page header image",
70+
localized: true,
71+
admin: {
72+
position: "sidebar",
73+
},
74+
}),
5675
],
5776
timestamps: true,
5877
};

apps/trustlab/src/utils/reports.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ export async function getReport(api, slug) {
6060
backgroundColor: "#010101",
6161
textColor: "#FFFFFF",
6262
id: report.id,
63+
description: report.pageHeaderDescription || "",
64+
image: report.pageHeaderImage || null,
6365
},
6466
{
6567
blockType: "page-overview",

0 commit comments

Comments
 (0)