|
|
|
@ -2,13 +2,10 @@ import React from 'react'
|
|
|
|
|
import Router from 'next/router'
|
|
|
|
|
|
|
|
|
|
import EmbedPage from './index'
|
|
|
|
|
import ApiContext from '../../components/ApiContext'
|
|
|
|
|
|
|
|
|
|
import api from '../../lib/api'
|
|
|
|
|
|
|
|
|
|
class EmbedIdPage extends React.PureComponent {
|
|
|
|
|
static contextType = ApiContext
|
|
|
|
|
static async getInitialProps({ req, res, query }) {
|
|
|
|
|
export async function getServerSideProps({ req, res, query }) {
|
|
|
|
|
const path = query.id
|
|
|
|
|
const parameter = path.length >= 19 && path.indexOf('.') < 0 ? path : null
|
|
|
|
|
|
|
|
|
@ -17,7 +14,7 @@ class EmbedIdPage extends React.PureComponent {
|
|
|
|
|
const host = req ? req.headers.host : undefined
|
|
|
|
|
snippet = await api.snippet.get(parameter, { host })
|
|
|
|
|
if (snippet /* && snippet.gist_id */) {
|
|
|
|
|
return { snippet }
|
|
|
|
|
return { props: { snippet } }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 404 Not found
|
|
|
|
@ -31,12 +28,9 @@ class EmbedIdPage extends React.PureComponent {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {}
|
|
|
|
|
return { props: {} }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
return <EmbedPage {...this.props} />
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default EmbedIdPage
|
|
|
|
|
export default React.memo(function EmbedIdPage(props) {
|
|
|
|
|
return <EmbedPage {...props} />
|
|
|
|
|
})
|
|
|
|
|