|
|
@ -6,13 +6,14 @@ import EmbedPage from './index'
|
|
|
|
import api from '../../lib/api'
|
|
|
|
import api from '../../lib/api'
|
|
|
|
|
|
|
|
|
|
|
|
export async function getServerSideProps({ req, res, query }) {
|
|
|
|
export async function getServerSideProps({ req, res, query }) {
|
|
|
|
const path = query.id
|
|
|
|
const { id: path, filename } = query
|
|
|
|
|
|
|
|
|
|
|
|
const parameter = path.length >= 19 && path.indexOf('.') < 0 ? path : null
|
|
|
|
const parameter = path.length >= 19 && path.indexOf('.') < 0 ? path : null
|
|
|
|
|
|
|
|
|
|
|
|
let snippet
|
|
|
|
let snippet
|
|
|
|
if (parameter) {
|
|
|
|
if (parameter) {
|
|
|
|
const host = req ? req.headers.host : undefined
|
|
|
|
const host = req ? req.headers.host : undefined
|
|
|
|
snippet = await api.snippet.get(parameter, { host })
|
|
|
|
snippet = await api.snippet.get(parameter, { host, filename })
|
|
|
|
if (snippet /* && snippet.gist_id */) {
|
|
|
|
if (snippet /* && snippet.gist_id */) {
|
|
|
|
return { props: { snippet } }
|
|
|
|
return { props: { snippet } }
|
|
|
|
}
|
|
|
|
}
|
|
|
|