import { GetServerSideProps, NextPage } from "next"; import NextError from "next/error"; import React from "react"; import ReactMarkdown from "react-markdown"; import { Card } from "../../common/Card"; import { Collapsible } from "../../common/Collapsible"; import { CopyParagraph } from "../../common/CopyParagraph"; import { Layout } from "../../common/Layout"; import { Query } from "../../common/Query"; import { QuestionWithHistoryFragment } from "../../fragments.generated"; import { ssrUrql } from "../../urql"; import { getBasePath } from "../../utils"; import { CaptureQuestion } from "../components/CaptureQuestion"; import { IndicatorsTable } from "../components/IndicatorsTable"; import { QuestionChartOrVisualization } from "../components/QuestionChartOrVisualization"; import { QuestionInfoRow } from "../components/QuestionInfoRow"; import { QuestionTitle } from "../components/QuestionTitle"; import { QuestionPageDocument } from "../queries.generated"; interface Props { id: string; } export const getServerSideProps: GetServerSideProps = async ( context ) => { const [ssrCache, client] = ssrUrql(); const id = context.query.id as string; const question = (await client.query(QuestionPageDocument, { id }).toPromise()).data ?.result || null; if (!question) { context.res.statusCode = 404; } return { props: { urqlState: ssrCache.extractData(), id, }, }; }; const Section: React.FC<{ title: string; id?: string }> = ({ title, children, id, }) => (

{title} {id ? ( <> {" "} # ) : null}

{children}
); const EmbedSection: React.FC<{ question: QuestionWithHistoryFragment }> = ({ question, }) => { const url = getBasePath() + `/questions/embed/${question.id}`; return (
`} buttonText="Copy HTML" />
{() =>