[examples/ckan][m] - add DMS option
This commit is contained in:
@@ -1,6 +1,11 @@
|
|||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
reactStrictMode: true,
|
reactStrictMode: true,
|
||||||
}
|
publicRuntimeConfig: {
|
||||||
|
DMS: process.env.DMS
|
||||||
|
? process.env.DMS.replace(/\/?$/, '')
|
||||||
|
: 'https://demo.dev.datopian.com/',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = nextConfig
|
module.exports = nextConfig;
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ import {
|
|||||||
PaperClipIcon,
|
PaperClipIcon,
|
||||||
} from "@heroicons/react/20/solid";
|
} from "@heroicons/react/20/solid";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import getConfig from "next/config";
|
||||||
|
|
||||||
|
const backend_url = getConfig().publicRuntimeConfig.DMS
|
||||||
|
|
||||||
export const getServerSideProps = async (context: any) => {
|
export const getServerSideProps = async (context: any) => {
|
||||||
try {
|
try {
|
||||||
@@ -15,7 +18,7 @@ export const getServerSideProps = async (context: any) => {
|
|||||||
notFound: true,
|
notFound: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const ckan = new CKAN("https://demo.dev.datopian.com");
|
const ckan = new CKAN(backend_url);
|
||||||
const dataset = await ckan.getDatasetDetails(datasetName as string);
|
const dataset = await ckan.getDatasetDetails(datasetName as string);
|
||||||
if (!dataset) {
|
if (!dataset) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -6,10 +6,13 @@ import {
|
|||||||
Organization,
|
Organization,
|
||||||
Group,
|
Group,
|
||||||
} from "@portaljs/ckan";
|
} from "@portaljs/ckan";
|
||||||
|
import getConfig from "next/config";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
|
const backend_url = getConfig().publicRuntimeConfig.DMS
|
||||||
|
|
||||||
export async function getServerSideProps() {
|
export async function getServerSideProps() {
|
||||||
const ckan = new CKAN("https://demo.dev.datopian.com");
|
const ckan = new CKAN(backend_url);
|
||||||
const groups = await ckan.getGroupsWithDetails();
|
const groups = await ckan.getGroupsWithDetails();
|
||||||
const orgs = await ckan.getOrgsWithDetails();
|
const orgs = await ckan.getOrgsWithDetails();
|
||||||
return {
|
return {
|
||||||
@@ -27,7 +30,7 @@ export default function Home({
|
|||||||
orgs: Organization[];
|
orgs: Organization[];
|
||||||
groups: Group[];
|
groups: Group[];
|
||||||
}) {
|
}) {
|
||||||
const ckan = new CKAN("https://demo.dev.datopian.com");
|
const ckan = new CKAN(backend_url);
|
||||||
const [options, setOptions] = useState<PackageSearchOptions>({
|
const [options, setOptions] = useState<PackageSearchOptions>({
|
||||||
offset: 0,
|
offset: 0,
|
||||||
limit: 5,
|
limit: 5,
|
||||||
|
|||||||
Reference in New Issue
Block a user