Skip to content

Commit

Permalink
fix: adaptor history share link (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongyunWan authored Jan 19, 2025
1 parent 19378b0 commit 9b21333
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion osgraph-web/src/result/translator/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import {
GRAPH_EXTEND_PARAMS_MAP,
GRAPH_LIMIT_MAP,
GRAPH_SHARE_LINK_MAP,
} from "../../constants/index";
import {
dateToTimestamp,
Expand All @@ -18,9 +19,31 @@ const graphTranslator = () => {
const pattern = /^\/graphs\/([^\/]+)\/github\/(\S+)/;
const match = url.match(pattern);

const adaptorHistoryTemplateType = (type: string) => {
if (GRAPH_SHARE_LINK_MAP.repo_contribute === type) {
return 'project-contribution';
}
else if (GRAPH_SHARE_LINK_MAP.repo_ecology === type) {
return 'project-ecosystem';
}
else if (GRAPH_SHARE_LINK_MAP.repo_community === type) {
return 'project-community';
}
else if (GRAPH_SHARE_LINK_MAP.acct_activity === type) {
return 'developer-activity';
}
else if (GRAPH_SHARE_LINK_MAP.acct_partner === type) {
return 'os-partner';
}
else if (GRAPH_SHARE_LINK_MAP.acct_interest === type) {
return 'os-interest';
}
return type;
};

if (match) {
return {
templateType: match[1],
templateType: adaptorHistoryTemplateType(match[1]),
path: match[2],
};
} else {
Expand Down Expand Up @@ -107,6 +130,8 @@ const graphTranslator = () => {

const urlValues = extractValuesFromURL(location.pathname);

console.log('urlValues:', urlValues);

return {
templateType: urlValues.templateType,
path: urlValues.path,
Expand Down

0 comments on commit 9b21333

Please sign in to comment.