diff --git a/app/(datasets)/data-catalog/page.tsx b/app/(datasets)/data-catalog/page.tsx index 0b4315f..9bf4b22 100644 --- a/app/(datasets)/data-catalog/page.tsx +++ b/app/(datasets)/data-catalog/page.tsx @@ -1,19 +1,18 @@ import React from 'react'; -import { getDatasets } from 'app/content/utils/mdx'; +import { getTransformedDatasetMetadata } from 'app/content/utils/mdx'; import { Suspense } from 'react'; import Catalog from './catalog'; -import { transformData } from '@helpers/data'; export default function Page() { - const posts: any[] = getDatasets(); // @TODO: Revist type here, should use data types from veda-ui - const transformed = transformData(posts); + const transformed = getTransformedDatasetMetadata(); return ( -
-

Datasets

- Loading...}> - - -
+
+
+ Loading...}> + + +
+
); } diff --git a/app/(datasets)/exploration/exploration.tsx b/app/(datasets)/exploration/exploration.tsx index 773ab99..1d3d03e 100644 --- a/app/(datasets)/exploration/exploration.tsx +++ b/app/(datasets)/exploration/exploration.tsx @@ -7,35 +7,19 @@ import { useTimelineDatasetAtom, externalDatasetsAtom, } from 'app/lib'; + import { useSetAtom } from 'jotai'; +import useElemengHeight from '@utils/hooks/use-element-height'; export default function ExplorationAnalysis({ datasets }: { datasets: any }) { - const transformData = () => { - const data = datasets?.map((post) => ({ - ...post.metadata, - })); - - const result = data?.map((d) => { - const updatedTax = d.taxonomy.map((t) => { - const updatedVals = t.values.map((v) => { - return { - id: v.replace(/ /g, '_').toLowerCase(), - name: v, - }; - }); - return { ...t, values: updatedVals }; - }); - return { ...d, taxonomy: updatedTax }; - }); - - return result; - }; - - const transformed = transformData(); - const setExternalDatasets = useSetAtom(externalDatasetsAtom); - setExternalDatasets(transformed); + setExternalDatasets(datasets); + + const [timelineDatasets, setTimelineDatasets] = useTimelineDatasetAtom(); + const [datasetModalRevealed, setDatasetModalRevealed] = useState( + !timelineDatasets.length, + ); const openModal = () => { setDatasetModalRevealed(true); @@ -43,14 +27,20 @@ export default function ExplorationAnalysis({ datasets }: { datasets: any }) { const closeModal = () => { setDatasetModalRevealed(false); }; - - const [timelineDatasets, setTimelineDatasets] = useTimelineDatasetAtom(); - const [datasetModalRevealed, setDatasetModalRevealed] = useState( - !timelineDatasets.length, - ); + // On landing, measure the height of Header and fill up the rest of the space with E&A + const offsetHeight = useElemengHeight({ queryToSelect: 'header' }); return ( - <> +
- +
); } diff --git a/app/(datasets)/exploration/page.tsx b/app/(datasets)/exploration/page.tsx index 6e210f0..c14be75 100644 --- a/app/(datasets)/exploration/page.tsx +++ b/app/(datasets)/exploration/page.tsx @@ -1,28 +1,16 @@ import React, { Suspense } from 'react'; -import { getDatasets } from 'app/content/utils/mdx'; +import { getTransformedDatasetMetadata } from 'app/content/utils/mdx'; import ExplorationAnalysis from './exploration'; import { PageHero } from 'app/lib'; export default function Page() { - const datasets: any[] = getDatasets(); + const datasets: any[] = getTransformedDatasetMetadata(); return (
-
- Loading...}> - - - -
+ Loading...}> + + +
); } diff --git a/app/(datasets)/stories/page.tsx b/app/(datasets)/stories/page.tsx index 363d0ea..cf58195 100644 --- a/app/(datasets)/stories/page.tsx +++ b/app/(datasets)/stories/page.tsx @@ -3,12 +3,16 @@ import { getStoriesMetadata } from 'app/content/utils/mdx'; import Hub from './hub'; export default function Page() { - const stories = getStoriesMetadata().map(d => ({...d.metadata, path: `stories/${d.slug}`})); + const stories = getStoriesMetadata().map((d) => ({ + ...d.metadata, + path: `stories/${d.slug}`, + })); return (
-

Stories

- +
+ +
); } diff --git a/app/about/page.tsx b/app/about/page.tsx new file mode 100644 index 0000000..472fe9d --- /dev/null +++ b/app/about/page.tsx @@ -0,0 +1,9 @@ +import React from 'react'; + +export default function Page() { + return ( +
+

About Page

+
+ ); +} diff --git a/app/content/utils/mdx.ts b/app/content/utils/mdx.ts index abed815..e4733bf 100644 --- a/app/content/utils/mdx.ts +++ b/app/content/utils/mdx.ts @@ -6,40 +6,6 @@ import { DatasetLayer, StoryData } from 'app/types/veda'; const md = markdownit(); -export function resolveConfigFunctions(datum, bag); -export function resolveConfigFunctions(datum, bag); -export function resolveConfigFunctions(datum, bag): any { - if (Array.isArray(datum)) { - return datum.map((v) => resolveConfigFunctions(v, bag)); - } - - if (datum != null && typeof datum === 'object') { - // Use for loop instead of reduce as it faster. - const ready = {}; - for (const [k, v] of Object.entries(datum as object)) { - ready[k] = resolveConfigFunctions(v, bag); - } - return ready; - } - - if (typeof datum === 'function') { - try { - return datum(bag); - } catch (error) { - /* eslint-disable-next-line no-console */ - console.error( - 'Failed to resolve function %s(%o) with error %s', - datum.name, - bag, - error.message, - ); - return null; - } - } - - return datum; -} - function parseAttributes(obj) { const convert = (obj) => { return Object.keys(obj).reduce( @@ -115,6 +81,27 @@ function getMDXMetaData(dir) { }); } +const transformData = (content: any) => { + const data = content?.map((post) => ({ + ...post.metadata, + })); + + const result = data?.map((d) => { + const updatedTax = d.taxonomy.map((t) => { + const updatedVals = t.values.map((v) => { + return { + id: v.replace(/ /g, '_').toLowerCase(), + name: v, + }; + }); + return { ...t, values: updatedVals }; + }); + return { ...d, taxonomy: updatedTax }; + }); + + return result; +}; + export function getStoriesMetadata() { return getMDXMetaData(path.join(process.cwd(), 'app', 'content', 'stories')); } @@ -127,6 +114,14 @@ export function getDatasets() { return getMDXData(path.join(process.cwd(), 'app', 'content', 'datasets')); } +export function getTransformedDatasetMetadata() { + return transformData(getDatasetsMetadata()); +} + +export function getTransformedDatasets() { + return transformData(getDatasets()); +} + export function getStories() { return getMDXData(path.join(process.cwd(), 'app', 'content', 'stories')); } diff --git a/app/layout.tsx b/app/layout.tsx index c09434d..c7c4411 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -64,7 +64,6 @@ export default function RootLayout({ > {children} -