Skip to content

Commit 5926618

Browse files
authored
Merge pull request #6778 from vr-varad/fix/edit_this_page_link
Fix: Broken Links on Members and Handbook
2 parents 83c66fe + 2aed60f commit 5926618

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

src/sections/General/Footer/index.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const Footer = ({ location }) => {
1111
var currentYear = new Date().getFullYear();
1212

1313
const getUrl = (pathname) => {
14-
//remove ".html" that results in live production build
14+
// remove ".html" that results in live production build
1515
if (pathname.endsWith(".html")) {
1616
pathname = pathname.replace(".html", "");
1717
}
@@ -28,6 +28,7 @@ const Footer = ({ location }) => {
2828
"/resources",
2929
"/learn",
3030
];
31+
3132
const test = {
3233
mdx: function (path) {
3334
let returnPath = "";
@@ -50,22 +51,36 @@ const Footer = ({ location }) => {
5051
}) && `src/collections${returnPath}`
5152
);
5253
},
54+
5355
learningPath: function (path) {
5456
return (
5557
path.startsWith("/learn/learning-paths/") &&
5658
`content-learn${pathname.replace("learn/learning-paths/", "")}`
5759
);
5860
},
61+
62+
communityMember: function (path) {
63+
if (path.startsWith("/community/members/")) {
64+
const memberId = path.replace("/community/members/", "");
65+
return `src/collections/members/${memberId}/index.mdx`;
66+
}
67+
return null;
68+
},
5969
};
6070

71+
if (pathname.startsWith("/community/handbook/")) {
72+
const page = pathname.replace("/community/handbook/", "");
73+
return `https://github.com/layer5io/layer5/blob/master/src/pages/community/handbook/${page}.js`;
74+
}
75+
6176
return test.mdx(pathname)
6277
? `https://github.com/layer5io/layer5/tree/master/${test.mdx(pathname)}`
6378
: test.learningPath(pathname)
64-
? `https://github.com/layer5io/layer5/tree/master/${test.learningPath(
65-
pathname
66-
)}`
67-
: `https://github.com/layer5io/layer5/blob/master/src/pages${pathname == "/" ? "" : pathname
68-
}${indexUrl.some((str) => pathname.endsWith(str)) ? "/index" : ""}.js`;
79+
? `https://github.com/layer5io/layer5/tree/master/${test.learningPath(pathname)}`
80+
: test.communityMember(pathname)
81+
? `https://github.com/layer5io/layer5/blob/master/${test.communityMember(pathname)}`
82+
: `https://github.com/layer5io/layer5/blob/master/src/pages${pathname == "/" ? "" : pathname
83+
}${indexUrl.some((str) => pathname.endsWith(str)) ? "/index" : ""}.js`;
6984
};
7085

7186
return (

0 commit comments

Comments
 (0)