import React from 'react' import { PlotlyChart, ReadMe, DataExplorer, } from 'portal' import path from 'path' import Head from 'next/head' import { getDataset } from '../lib/dataset' import { addView } from '../lib/utils' const datasetsDirectory = process.env.PORTAL_DATASET_PATH || path.join(process.cwd(), "public", "country-codes") export default function Home({ dataset, specs }) { if (!dataset || dataset.hasError) { return (
Dataset

) } const descriptor = dataset['descriptor'] const resources = dataset['resources'] return (
Dataset

{descriptor.title}

Graph

{!specs || Object.keys(specs).length == 0 ? (

No graph to display

) : ( Object.values(JSON.parse(specs)).map((spec, i) => { if (["simple", "plotly"].includes(spec.specType)) { return (
) } }) )}

Data Preview

{ dataset.readmeHtml != "" ? (

README

) : ( "" ) }
) } export async function getStaticProps() { const dataset = await getDataset(datasetsDirectory) if (dataset.hasError == true) { return { props: { dataset } } } else { const datasetWithViews = addView(dataset) return datasetWithViews } }