mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 21:06:42 +07:00
fixed youtube block
This commit is contained in:
parent
93afa626db
commit
b87487ed1f
7 changed files with 34 additions and 7 deletions
23
src/components/comment/CommentEmbedBlock/index.tsx
Normal file
23
src/components/comment/CommentEmbedBlock/index.tsx
Normal file
|
@ -0,0 +1,23 @@
|
|||
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 };
|
3
src/components/comment/CommentEmbedBlock/styles.scss
Normal file
3
src/components/comment/CommentEmbedBlock/styles.scss
Normal file
|
@ -0,0 +1,3 @@
|
|||
.text {
|
||||
padding: 0 $gap;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue