mirror of
https://github.com/glitch-soc/mastodon.git
synced 2024-11-29 19:40:23 -05:00
5b67389bba
Port 01b6c83c36
to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
30 lines
826 B
TypeScript
30 lines
826 B
TypeScript
import CheckIcon from '@/material-icons/400-24px/check.svg?react';
|
|
|
|
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' icon={CheckIcon} className='verified-badge__mark' />
|
|
<span dangerouslySetInnerHTML={stripRelMe(link)} />
|
|
</span>
|
|
);
|