diff --git a/components/dataset/About.tsx b/components/dataset/About.tsx new file mode 100644 index 00000000..2f9fd992 --- /dev/null +++ b/components/dataset/About.tsx @@ -0,0 +1,37 @@ +export default function About({ datapackage }) { + return ( + <> +

{ datapackage.title || datapackage.name }

+ + + + + + + + + + + + + + + + + + + + + + + +
FilesSizeFormatCreatedUpdatedLicenseSource
{ datapackage.resources.length }{ datapackage.size || 'N\A' } + + { datapackage.created }{ datapackage.modified } + + + +
+ + ) +} diff --git a/components/dataset/Org.tsx b/components/dataset/Org.tsx new file mode 100644 index 00000000..206d3b00 --- /dev/null +++ b/components/dataset/Org.tsx @@ -0,0 +1,9 @@ +import Link from 'next/link' + +export default function Org({ org }) { + return ( + + { org.title || org.name } + + ) +} diff --git a/components/dataset/Resources.tsx b/components/dataset/Resources.tsx new file mode 100644 index 00000000..e3889168 --- /dev/null +++ b/components/dataset/Resources.tsx @@ -0,0 +1,16 @@ +import Link from 'next/link' + +export default function Resources({ resources }) { + return ( + + ) +} diff --git a/pages/[org]/[dataset]/index.tsx b/pages/[org]/[dataset]/index.tsx index a2582208..c89eedd2 100644 --- a/pages/[org]/[dataset]/index.tsx +++ b/pages/[org]/[dataset]/index.tsx @@ -1,3 +1,25 @@ -export default function Dataset() { - return

Dataset page

+import { GetServerSideProps } from 'next' +import config from '../../../config' +import utils from '../../../utils' +import About from '../../../components/dataset/About' +import Org from '../../../components/dataset/Org' +import Resources from '../../../components/dataset/Resources' + +function Dataset({ datapackage }) { + return ( + <> + + + + + ) } + +export const getServerSideProps: GetServerSideProps = async (context) => { + const res = await fetch(`${config.get('DMS')}/api/3/action/package_show?id=${context.query.dataset}`) + const ckanResult = (await res.json()).result + const datapackage = utils.ckanToDataPackage(ckanResult) + return { props: { datapackage } } +} + +export default Dataset diff --git a/pages/search.tsx b/pages/search.tsx index d57b8397..f43c67d1 100644 --- a/pages/search.tsx +++ b/pages/search.tsx @@ -23,7 +23,6 @@ export const getServerSideProps: GetServerSideProps = async (context) => { const ckanQuery = querystring.stringify( utils.convertToCkanSearchQuery(query) ) - console.log(ckanQuery) const res = await fetch(`${config.get('DMS')}/api/3/action/package_search?${ckanQuery}`) const ckanResult = (await res.json()).result const datapackages = ckanResult.results.map(item => utils.ckanToDataPackage(item))