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;
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
.text {
|
||||
padding: $gap;
|
||||
padding: 0 $gap;
|
||||
font-weight: 300;
|
||||
font: $font_16_medium;
|
||||
line-height: 20px;
|
||||
|
|
|
@ -31,7 +31,7 @@ const CommentContent: FC<IProps> = memo(({ comment }) => {
|
|||
return (
|
||||
<>
|
||||
{comment.text && (
|
||||
<div className={styles.block}>
|
||||
<Group className={styles.block}>
|
||||
{formatCommentText(path(['user', 'username'], comment), comment.text).map(
|
||||
(block, key) =>
|
||||
COMMENT_BLOCK_RENDERERS[block.type] &&
|
||||
|
@ -39,7 +39,7 @@ const CommentContent: FC<IProps> = memo(({ comment }) => {
|
|||
)}
|
||||
|
||||
<div className={styles.date}>{getPrettyDate(comment.created_at)}</div>
|
||||
</div>
|
||||
</Group>
|
||||
)}
|
||||
|
||||
{groupped.image && groupped.image.length > 0 && (
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
padding-bottom: 10px;
|
||||
box-sizing: border-box;
|
||||
flex-direction: column;
|
||||
padding: $gap 0;
|
||||
|
||||
&:first-child {
|
||||
border-top-right-radius: $radius;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue