/* Imports */ import { GetServerSideProps, NextPage } from "next"; import React from "react"; import { getPlatforms } from "../backend/platforms/registry"; import { QuestionFragment } from "../web/fragments.generated"; import { QuestionCard } from "../web/questions/components/QuestionCard"; import { SearchDocument } from "../web/search/queries.generated"; import { ssrUrql } from "../web/urql"; interface Props { results: QuestionFragment[]; } export const getServerSideProps: GetServerSideProps = async ( context ) => { const [ssrCache, client] = ssrUrql(); let urlQuery = context.query; let initialQueryParameters = { query: "", starsThreshold: 2, forecastsThreshold: 0, forecastingPlatforms: getPlatforms().map((platform) => platform.name), ...urlQuery, }; let results: QuestionFragment[] = []; if (initialQueryParameters.query !== "") { const response = await client .query(SearchDocument, { input: { ...initialQueryParameters, limit: 1, }, }) .toPromise(); if (response.data?.result) { results = response.data.result; } else { throw new Error("GraphQL request failed"); } } return { props: { urqlState: ssrCache.extractData(), results, }, }; }; const SecretEmbedPage: NextPage = ({ results }) => { let result = results.length ? results[0] : null; return (
{result ? ( ) : null}


{result ? JSON.stringify(result, null, 4) : null}
); }; export default SecretEmbedPage;