youtube, intagram, html tokens support
This commit is contained in:
1 parent
a13b642979
commit
be836c42be
1 file changed
+42
@@ -9,6 +9,7 @@ import { createApiUrl, requestGet, IResponseItems } from 'src/next-lib'
|
|||||||
import { NextPage } from 'next'
|
import { NextPage } from 'next'
|
||||||
import { IBreadcumbsPart, IMeta, IPage, ITag, FileTokenData, Token } from 'src/types'
|
import { IBreadcumbsPart, IMeta, IPage, ITag, FileTokenData, Token } from 'src/types'
|
||||||
import { joinTokens } from 'src/lib/tokens'
|
import { joinTokens } from 'src/lib/tokens'
|
||||||
|
import { Html } from 'src/components/Html'
|
||||||
|
|
||||||
function array<T>(value: T | T[]) {
|
function array<T>(value: T | T[]) {
|
||||||
return Array.isArray(value)
|
return Array.isArray(value)
|
||||||
@@ -16,6 +17,26 @@ 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 => (
|
||||||
<div className="document-row">
|
<div className="document-row">
|
||||||
<a href={props['url']} className="invisible">
|
<a href={props['url']} className="invisible">
|
||||||
@@ -74,6 +95,27 @@ const Index: NextPage<Props> = props => (
|
|||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
case 'html':
|
||||||
|
return (
|
||||||
|
<Html
|
||||||
|
html={x.data}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
|
||||||
|
case 'instagram':
|
||||||
|
return (
|
||||||
|
<Html
|
||||||
|
html={x.data.embed}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
|
||||||
|
case 'youtube':
|
||||||
|
return (
|
||||||
|
<Youtube
|
||||||
|
url={x.data.url}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
|
||||||
case 'image':
|
case 'image':
|
||||||
return (
|
return (
|
||||||
<div className="kazimir__image">
|
<div className="kazimir__image">
|
||||||
|
|||||||
Reference in new issue
Block a user