From 3ac0ee46532c4d6b0f8cc2130b886faa9c3f5f98 Mon Sep 17 00:00:00 2001 From: Rising Odegua Date: Mon, 31 Jan 2022 13:12:14 +0100 Subject: [PATCH] Update page to properly display error message --- examples/dataset-frictionless/pages/index.js | 45 +++++++++++++------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/examples/dataset-frictionless/pages/index.js b/examples/dataset-frictionless/pages/index.js index 067c1c82..2b8931b1 100644 --- a/examples/dataset-frictionless/pages/index.js +++ b/examples/dataset-frictionless/pages/index.js @@ -14,7 +14,7 @@ const datasetsDirectory = process.env.PORTAL_DATASET_PATH || path.join(process.c export default function Home({ dataset, specs }) { - if (!dataset) { + if (!dataset || dataset.hasError) { return (
@@ -23,8 +23,10 @@ export default function Home({ dataset, specs }) { -

- No dataset found in path +

) @@ -48,11 +50,11 @@ export default function Home({ dataset, specs }) { -
+
-
+
@@ -85,10 +87,18 @@ export default function Home({ dataset, specs }) { )}
-
-

README

- -
+ { + dataset.readmeHtml != "" ? ( +
+ +

README

+ +
+ ) : ( + "" + ) + } + ) @@ -96,12 +106,17 @@ export default function Home({ dataset, specs }) { export async function getStaticProps() { - if (!datasetsDirectory) { - return { props: {} } + const dataset = await getDataset(datasetsDirectory) + + if (dataset.hasError == true) { + return { + props: { + dataset + } + } + } else { + const datasetWithViews = addView(dataset) + return datasetWithViews } - const dataset = await getDataset(datasetsDirectory) - const datasetWithViews = addView(dataset) - return datasetWithViews - }