1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 04:46:40 +07:00
vault-frontend/src/components/comment/CommentEmbedBlock/index.tsx
2019-11-26 11:07:40 +07:00

23 lines
523 B
TypeScript

import React, { FC, memo } from 'react';
import { ICommentBlock } from '~/constants/comment';
import styles from './styles.scss';
interface IProps {
block: ICommentBlock;
}
const CommentEmbedBlock: FC<IProps> = memo(({ block }) => {
const link = block.content.match(
/(https?:\/\/(www\.)?(youtube\.com|youtu\.be)\/(watch)?(\?v=)?[\w\-]+)/gi
);
return (
<div className={styles.text}>
<a href={link[0]} target="_blank">
{link[0]}
</a>
</div>
);
});
export { CommentEmbedBlock };