Co-authored-by: tobi <tobi.smethurst@protonmail.com> Reviewed-on: https://codeberg.org/superseriousbusiness/masto-fe-standalone/pulls/88 Co-authored-by: Zoë Bijl <moiety@noreply.codeberg.org> Co-committed-by: Zoë Bijl <moiety@noreply.codeberg.org>
28 lines
741 B
TypeScript
28 lines
741 B
TypeScript
import { Icon } from "./icon";
|
|
|
|
const domParser = new DOMParser();
|
|
|
|
const stripRelMe = (html: string) => {
|
|
const document = domParser.parseFromString(html, "text/html").documentElement;
|
|
|
|
document.querySelectorAll<HTMLAnchorElement>("a[rel]").forEach((link) => {
|
|
link.rel = link.rel
|
|
.split(" ")
|
|
.filter((x: string) => x !== "me")
|
|
.join(" ");
|
|
});
|
|
|
|
const body = document.querySelector("body");
|
|
return body ? { __html: body.innerHTML } : undefined;
|
|
};
|
|
|
|
interface Props {
|
|
link: string,
|
|
}
|
|
export const VerifiedBadge: React.FC<Props> = ({ link }) => (
|
|
<span className='verified-badge'>
|
|
<Icon id='check' className='verified-badge__mark' />
|
|
<span dangerouslySetInnerHTML={stripRelMe(link)} />
|
|
</span>
|
|
);
|