Skip to content
This repository has been archived by the owner on Mar 12, 2023. It is now read-only.

🎉 Support video embed youtube #93

Merged

Conversation

herohoro
Copy link
Contributor

Video block_youtube限定

  • Video blockにyoutubeリンクを設定した時にembedできます

スクリーンショット 2022-06-19 20 51 32

埋め込めるURL

  • 上部バーに表示されるURL

スクリーンショット 2022-06-19 19 59 55

  • 短縮URL

スクリーンショット 2022-06-19 20 00 22

埋め込むとブログ上で再生できます

スクリーンショット 2022-06-19 20 27 07

スクリーンショット 2022-06-19 20 27 22

@vercel
Copy link

vercel bot commented Jun 19, 2022

Someone is attempting to deploy a commit to a Personal Account owned by @otoyo on Vercel.

@otoyo first needs to authorize it.

@herohoro
Copy link
Contributor Author

何とかYouTubeURLをvideo blockで埋め込めるようになりました。

漏れなどありましたら教えていただければと思います。
※ お忙しいかと思いますので時間ある時で構いませんm(_ _)m

@vercel
Copy link

vercel bot commented Jun 21, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
easy-notion-blog ✅ Ready (Inspect) Visit Preview Jun 21, 2022 at 0:36AM (UTC)

}
if (item.video.type === 'external') {
video.External = { Url: item.video.external.url }
} else {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この else ブロックは何も処理していないので不要です。

@@ -72,6 +73,10 @@ export interface Image {
Width?: number
Height?: number
}
export interface Video{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

上に1行空行を入れてください。

import YouTube, {YouTubeProps } from 'react-youtube';


const Video=({block})=> {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const Video=({block})=> {
const Video=({ block })=> {

{} の内側にはスペースを1個お願いします。

@@ -0,0 +1,32 @@
import styles from '../../styles/notion-block.module.css'
import React from 'react';
import YouTube, {YouTubeProps } from 'react-youtube';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import YouTube, {YouTubeProps } from 'react-youtube';
import YouTube, { YouTubeProps } from 'react-youtube';

{} の内側にはスペースを1個お願いします。

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

行末のセミコロンは不要です。

autoplay: 1,
},
};
console.log(VIDEOS)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console.log が残っているので削除お願いします。

const VIDEOS =url.match(/(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)(?:\/watch\?v=|\/)([^\s&]+)/);
const videoID=""+VIDEOS[1]+"";

//npm
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このコメントも特に意味はないと思うので削除をお願いします。


const Video=({block})=> {
const url = block.Video.External.Url
const VIDEOS =url.match(/(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)(?:\/watch\?v=|\/)([^\s&]+)/);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

URLが来ることはわかっているため全て正規表現でマッチするより URL インターフェースを使う方が保守性の面で優れています。

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

= の両側にスペースをお願いします。

const Video=({block})=> {
const url = block.Video.External.Url
const VIDEOS =url.match(/(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)(?:\/watch\?v=|\/)([^\s&]+)/);
const videoID=""+VIDEOS[1]+"";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=+ の両側にスペースをお願いします。

@otoyo
Copy link
Owner

otoyo commented Jun 21, 2022

96f813c のコミットは全て指摘していくとかなり多くなってしまうので私の方で修正しておきます。
全体として動作していることは確認できました。機能追加ありがとうございます。

@herohoro
Copy link
Contributor Author

いろいろツメが甘くてすみませんでした💦💦

@otoyo
Copy link
Owner

otoyo commented Jun 21, 2022

コードのスタイルに関してはエディタにプラグインを入れるなどすれば自動でフォーマットしてくれるので試してみてください。
エディタの名前と TypeScript、フォーマッタなどで検索すると導入方法が出てくると思います。

@otoyo otoyo changed the base branch from main to support-youtube-video-blocks June 21, 2022 12:47
@herohoro
Copy link
Contributor Author

フォーマッタですね!?
code sandboxのようなことをしてくれる機能があるのですね!?
早速探して導入します!!!
ありがとうございますー\\\٩( 'ω' )و ////

@otoyo
Copy link
Owner

otoyo commented Jun 21, 2022

修正があるため main ではなく下記のブランチに向けてマージしてしまいます。main に向ける際には PR を作ってお知らせしますね。
https://github.com/otoyo/easy-notion-blog/tree/support-youtube-video-blocks

@otoyo otoyo merged commit 2012ec1 into otoyo:support-youtube-video-blocks Jun 21, 2022
@otoyo otoyo deleted the Support_video-embed_youtube branch June 21, 2022 12:49
@herohoro
Copy link
Contributor Author

herohoro commented Jun 21, 2022

何から何までありがとうございます!!
修正がある場合、ブランチをここから分岐させて合流させるんですね(´-`).。oO
勉強になりますー


メモ

  • 赤:main
  • 青:今回修正のために用意していただいたブランチ

スクリーンショット 2022-06-22 11 43 05

※ mainブランチをroot/mainに同期できていないまま分岐させてしまっていてすみません(;´Д`)

@herohoro
Copy link
Contributor Author

コードのスタイルに関してはエディタにプラグインを入れるなどすれば自動でフォーマットしてくれるので試してみてください。

便利な拡張機能発見出来ました\(^o^)/
ありがとうございます〜〜〜〜。(すこぶる便利です)

スクリーンショット 2022-06-24 18 13 09

go to....pretter

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants