-
Notifications
You must be signed in to change notification settings - Fork 22
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
79f6ee2
commit 12b5690
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
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,42 @@ | ||
/* INCLUDE: "common.jsx" */ | ||
function href(widgetName, linkProps) { | ||
linkProps = { ...linkProps }; | ||
|
||
if (props.referral) { | ||
linkProps.referral = props.referral; | ||
} | ||
|
||
const linkPropsQuery = Object.entries(linkProps) | ||
.filter(([_key, nullable]) => (nullable ?? null) !== null) | ||
.map(([key, value]) => `${key}=${value}`) | ||
.join("&"); | ||
|
||
return `/#/${REPL_DEVHUB}/widget/devhub.page.${widgetName}${ | ||
linkPropsQuery ? "?" : "" | ||
}${linkPropsQuery}`; | ||
} | ||
/* END_INCLUDE: "common.jsx" */ | ||
|
||
if (!props.type) { | ||
return "Loading ..."; | ||
} | ||
|
||
const type = props.type.split("/")[1]; | ||
return props.type ? ( | ||
<> | ||
{type == "like" | ||
? "liked your" | ||
: type == "reply" | ||
? "replied to your" | ||
: type == "edit" | ||
? "edited your" | ||
: type == "mention" | ||
? "mentioned you in their" | ||
: "???"}{" "} | ||
<a className="fw-bold text-muted" href={href("post", { id: props.post })}> | ||
DevHub post | ||
</a> | ||
</> | ||
) : ( | ||
"Loading ..." | ||
); |
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,28 @@ | ||
/* INCLUDE: "common.jsx" */ | ||
function href(widgetName, linkProps) { | ||
linkProps = { ...linkProps }; | ||
|
||
if (props.referral) { | ||
linkProps.referral = props.referral; | ||
} | ||
|
||
const linkPropsQuery = Object.entries(linkProps) | ||
.filter(([_key, nullable]) => (nullable ?? null) !== null) | ||
.map(([key, value]) => `${key}=${value}`) | ||
.join("&"); | ||
|
||
return `/#/${REPL_DEVHUB}/widget/devhub.page.${widgetName}${ | ||
linkPropsQuery ? "?" : "" | ||
}${linkPropsQuery}`; | ||
} | ||
/* END_INCLUDE: "common.jsx" */ | ||
|
||
return props.post === undefined ? ( | ||
"Loading ..." | ||
) : ( | ||
<> | ||
<a className="btn btn-outline-dark" href={href("post", { id: props.post })}> | ||
View DevHub post | ||
</a> | ||
</> | ||
); |