2024-01-13 07:16:48 +11:00
|
|
|
import CheckIcon from 'mastodon/../material-icons/400-24px/check.svg?react';
|
2023-10-25 04:45:08 +11:00
|
|
|
|
2023-05-07 17:10:58 +10:00
|
|
|
import { Icon } from './icon';
|
|
|
|
|
2023-06-25 01:24:31 +10:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2023-05-10 20:59:29 +10:00
|
|
|
interface Props {
|
2023-05-07 17:10:58 +10:00
|
|
|
link: string;
|
2023-05-10 20:59:29 +10:00
|
|
|
}
|
2023-05-07 17:10:58 +10:00
|
|
|
export const VerifiedBadge: React.FC<Props> = ({ link }) => (
|
|
|
|
<span className='verified-badge'>
|
2023-10-25 04:45:08 +11:00
|
|
|
<Icon id='check' icon={CheckIcon} className='verified-badge__mark' />
|
2023-06-25 01:24:31 +10:00
|
|
|
<span dangerouslySetInnerHTML={stripRelMe(link)} />
|
2023-05-07 17:10:58 +10:00
|
|
|
</span>
|
|
|
|
);
|