import { GetServerSideProps } from 'next'; import gql from 'graphql-tag'; import { useQuery } from '@apollo/react-hooks'; import { initializeApollo } from '../../../../../lib/apolloClient'; import utils from '../../../../../utils'; import Head from 'next/head'; import Nav from '../../../../../components/home/Nav'; import About from '../../../../../components/resource/About'; import DataExplorer from '../../../../../components/resource/DataExplorer'; const QUERY = gql` query dataset($id: String) { dataset(id: $id) @rest(type: "Response", path: "package_show?{args}") { result { resources { name id title description format size created last_modified url } } } } `; function Resource({ variables }) { const { data, loading } = useQuery(QUERY, { variables }); if (loading) return
Loading
; const result = data.dataset.result; // Find right resource const resource = result.resources.find( (item) => item.name === variables.resource ); return ( <> Portal | {resource.title || resource.name}