/connect-ckan

/connect-ckan connects an existing PortalJS portal to a live CKAN backend. The portal stops reading static files from /public/data/ and instead lists and renders datasets straight from a CKAN instance's REST API (package_search / package_show) using the @portaljs/ckan client. The output is plain, editable Next.js code — no opaque framework wiring.

When to use it

Use it for the decoupled / any-backend path: you have a CKAN data management system (your own or a public one) and want a browseable portal in front of it. CKAN calls run server-side in getStaticProps / getStaticPaths, so the @portaljs/ckan bundle never reaches the browser and the site can still be statically deployed.

Inputs

InputRequiredNotes
CKAN base URLYesThe root of the instance, e.g. https://demo.dev.datopian.com. Must be publicly reachable.
Org filterNoOne or more CKAN organization names to restrict the catalog to.
Group filterNoOne or more CKAN group names to restrict the catalog to.
Portal directoryNoPath to the portal project. Defaults to the current directory.

The skill verifies the CKAN API is reachable (and that any named orgs exist) before generating code.

Example

/connect-ckan https://demo.dev.datopian.com

Restricted to specific organizations:

/connect-ckan https://demo.dev.datopian.com --org transport,environment

What it produces

  • @portaljs/ckan added to package.json, plus a tsconfig.json paths entry so TypeScript resolves the client's types.
  • lib/ckan.ts — a small, editable client module. The CKAN URL is the default, overridable at deploy time via the DMS env var; org/group filters and a build-time page cap (MAX_DATASETS) are plain constants you can edit.
  • pages/index.tsx rewritten to list datasets from package_search.
  • pages/datasets/[slug].tsx — a dynamic route that pre-renders one page per dataset via package_show, previewing CSV/TSV resources through the template's Table.

It verifies the build before reporting success. When it finishes:

✓ Connected to CKAN: https://demo.dev.datopian.com
  - Client:    lib/ckan.ts (DMS overridable via env var)
  - Home:      pages/index.tsx → lists datasets from package_search
  - Dataset:   pages/datasets/[slug].tsx → package_show, CSV/TSV preview via <Table>

The default is static generation (data fixed at build time — rebuild to pick up
new CKAN datasets). For always-live data, deploy to a Node host and switch to
getServerSideProps or getStaticPaths fallback: 'blocking'.

Where to go next

  • Core concepts — why the frontend is decoupled from the backend.
  • /deploy — publish the connected portal.