Skip to content

Commit

Permalink
Merge pull request #631 from CodeForAfrica/charterafrica/fix-links
Browse files Browse the repository at this point in the history
Fix go to repository broken link
  • Loading branch information
koechkevin committed Oct 6, 2023
2 parents aa24ccd + 57626a2 commit 73018e2
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 39 deletions.
2 changes: 1 addition & 1 deletion apps/charterafrica/contrib/dokku/Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM codeforafrica/charterafrica-ui:0.1.10
FROM codeforafrica/charterafrica-ui:0.1.11
2 changes: 1 addition & 1 deletion apps/charterafrica/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "charterafrica",
"version": "0.1.10",
"version": "0.1.11",
"private": true,
"author": "Code for Africa <[email protected]>",
"description": "This is the official code for https://charter.africa site",
Expand Down
28 changes: 15 additions & 13 deletions apps/charterafrica/src/components/Tool/Tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const Tool = React.forwardRef(function Tool(props, ref) {
const {
image,
name,
link,
organisation,
theme,
operatingCountries,
Expand All @@ -34,6 +33,7 @@ const Tool = React.forwardRef(function Tool(props, ref) {
partners,
tools,
toolsTitle,
externalLink,
} = props;
return (
<Box bgcolor="common.white" ref={ref}>
Expand Down Expand Up @@ -62,18 +62,20 @@ const Tool = React.forwardRef(function Tool(props, ref) {
<RichTypography color="neutral.dark" variant="h2SemiBold">
{name}
</RichTypography>
<Link href={link.href}>
<SvgIcon
inheritViewBox
component={ExternalLink}
sx={{
color: "text.primary",
fill: "none",
height: 32,
width: 32,
}}
/>
</Link>
{externalLink?.href ? (
<Link href={externalLink.href}>
<SvgIcon
inheritViewBox
component={ExternalLink}
sx={{
color: "text.primary",
fill: "none",
height: 32,
width: 32,
}}
/>
</Link>
) : null}
</Box>
</Grid>
<Grid item>
Expand Down
12 changes: 0 additions & 12 deletions apps/charterafrica/src/components/Tool/Tool.snap.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,6 @@ exports[`<Tool /> renders unchanged 1`] = `
>
Tool Name
</div>
<a
class="MuiTypography-root MuiTypography-inherit MuiLink-root MuiLink-underlineAlways active css-4xpak5-MuiTypography-root-MuiLink-root"
href="https://git.com"
rel="noreferrer noopener"
target="_blank"
>
<div
aria-hidden="true"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-mg30as-MuiSvgIcon-root"
focusable="false"
/>
</a>
</div>
</div>
<div
Expand Down
16 changes: 5 additions & 11 deletions apps/charterafrica/src/lib/data/common/processPageTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@ const queryBuilder = (query) => {
return where;
};

const getRepoLink = (tool) => {
switch (tool.source && tool.externalId) {
case "github":
return `https://github.com/${tool.externalId}`;
default:
return "";
}
};

async function processPageSingleTool(page, api, context) {
const { params, locale } = context;
const { slug: collection } = page;
Expand Down Expand Up @@ -79,11 +70,11 @@ async function processPageSingleTool(page, api, context) {
...tool,
slug: "tool",
contribute: {
href: getRepoLink(tool),
href: tool.repoLink,
label: filterLabels.contribute,
},
goToRepo: {
href: getRepoLink(tool),
href: tool.repoLink,
label: filterLabels.goToRepo,
},
topicLabel: filterLabels.theme,
Expand Down Expand Up @@ -113,6 +104,9 @@ async function processPageSingleTool(page, api, context) {
commitText: filterLabels.lastCommit,
forksText: filterLabels.forks,
starsText: filterLabels.stars,
externalLink: {
href: tool.docLink ?? null,
},
},
],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function nestCollectionUnderPage(pageSlug) {
} catch (error) {
// TODO(kilemensi): Add Sentry to payload & report errors
}
return { ...doc, link: { href } };
return { ...doc, docLink: doc.link ?? null, link: { href } };
};
}

Expand Down

0 comments on commit 73018e2

Please sign in to comment.