Youtube moved to component
This commit is contained in:
1 parent
1b303d79f4
commit
fc9ff7f1b2
2 files changed
+24
-20
No files matched your search
+1
-20
@@ -11,6 +11,7 @@ import { IBreadcumbsPart, IMeta, IPage, ITag, FileTokenData, Token } from 'src/t
|
|||||||
import { joinTokens } from 'src/lib/tokens'
|
import { joinTokens } from 'src/lib/tokens'
|
||||||
import { size, ext } from 'src/lib/file'
|
import { size, ext } from 'src/lib/file'
|
||||||
import { Html } from 'src/components/Html'
|
import { Html } from 'src/components/Html'
|
||||||
|
import { Youtube } from '@/components/Youtube'
|
||||||
|
|
||||||
function array<T>(value: T | T[]) {
|
function array<T>(value: T | T[]) {
|
||||||
return Array.isArray(value)
|
return Array.isArray(value)
|
||||||
@@ -18,26 +19,6 @@ function array<T>(value: T | T[]) {
|
|||||||
: [value]
|
: [value]
|
||||||
}
|
}
|
||||||
|
|
||||||
const Youtube: React.SFC<{ url: string }> = props => {
|
|
||||||
const url = new URL(props.url)
|
|
||||||
const videoId = url.searchParams.get('v')
|
|
||||||
if (!videoId) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
const src = `//www.youtube.com/embed/${videoId}`
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="kazimir__video">
|
|
||||||
<iframe
|
|
||||||
src={src}
|
|
||||||
frameBorder="0"
|
|
||||||
// allowFullscreen
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const File: React.SFC<FileTokenData> = props => {
|
const File: React.SFC<FileTokenData> = props => {
|
||||||
const fileSize = size(props.file_size)
|
const fileSize = size(props.file_size)
|
||||||
const format = ext(props.file_format)
|
const format = ext(props.file_format)
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
export type YoutubeProps = {
|
||||||
|
url: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Youtube: React.FC<{ url: string }> = props => {
|
||||||
|
const url = new URL(props.url)
|
||||||
|
const videoId = url.searchParams.get('v')
|
||||||
|
if (!videoId) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
const src = `//www.youtube.com/embed/${videoId}`
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="kazimir__video">
|
||||||
|
<iframe
|
||||||
|
src={src}
|
||||||
|
frameBorder="0"
|
||||||
|
// allowFullscreen
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
Reference in new issue
Block a user