{"data":{"slug":"github-datopian-portaljs-skills-portaljs-add-resource-7c09f4ac8f85","title":"PortalJS \u2014 Add Resource","summary":"Add a file (resource) to an existing dataset in a PortalJS portal. Use when a dataset needs a second file, such as a data dictionary, methodology doc, or an additional data file. The result includes a new section in the dataset's showcase, with the resource's file stored in `public\/data\/` and updated in `datasets.json`.","url":"https:\/\/skillshunter.net\/skills\/github-datopian-portaljs-skills-portaljs-add-resource-7c09f4ac8f85","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-datopian-portaljs-skills-portaljs-add-resource-7c09f4ac8f85","markdown_url":"https:\/\/skillshunter.net\/skills\/github-datopian-portaljs-skills-portaljs-add-resource-7c09f4ac8f85.md","download_url":"https:\/\/skillshunter.net\/skills\/github-datopian-portaljs-skills-portaljs-add-resource-7c09f4ac8f85\/download","category":{"slug":"data-research","name":"Data & Research"},"editor_note":"Prerequisites: An existing PortalJS portal with `datasets.json`, `package.json`, and `pages\/[owner]\/[slug].tsx` present. The target dataset must already be registered in `datasets.json`. The new resource's source must be a local file path or a public URL in CSV, TSV, JSON (array), or GeoJSON format. Node 18+ is required to run `npx next build` for verification.","instructions":"---\nname: portaljs-add-resource\ndescription: Add another file (resource) to an EXISTING dataset in a PortalJS portal \u2014 a data dictionary, methodology, or an additional data file. Turns a single-file dataset into a multi-resource one; the showcase renders a section per resource. Use when a dataset needs a second file, such as a data dictionary, methodology doc, or an additional period's data.\nallowed-tools: Read, Write, Edit, Bash(npm:*), Bash(curl:*), Bash(mkdir:*), Bash(cp:*), WebFetch\nversion: 1.0.0\nauthor: Datopian <hello@datopian.com>\nlicense: MIT\ncompatibility: Claude Code with PortalJS portals (Next.js 14, React 18, Node 18+). Runs from any project via the plugin, a personal ~\/.claude\/commands install, or a portaljs clone.\ntags:\n  - portaljs\n  - data-portal\n  - resource\n  - data-dictionary\n  - metadata\n  - catalog\n---\n\n# PortalJS \u2014 Add Resource\n\n## Overview\n\nAdd a resource \u2014 an additional file \u2014 to a dataset that already exists in a\n`portaljs-catalog` portal. Where `\/portaljs-add-dataset` creates a **new** dataset\n(one file), this skill adds a file to an **existing** one: a data dictionary, a\nmethodology document, or another data file (e.g. a second year's figures).\n\nMirrors the Frictionless Data Package model: a dataset holds a `resources[]` array,\nand the showcase at `\/@<namespace>\/<slug>` renders one section per resource (preview,\nschema, download). A single-file dataset migrates to `resources[]` automatically the\nfirst time a second file is added \u2014 no data is lost.\n\n## Prerequisites\n\n- An existing PortalJS portal (`portaljs-catalog` template) with `datasets.json`,\n  `package.json`, and `pages\/[owner]\/[slug].tsx` present.\n- The target dataset already registered in `datasets.json`.\n- The new resource's source: a local file path or a public URL, in CSV, TSV, JSON\n  (array), or GeoJSON format.\n- Node 18+ installed to run `npx next build` for verification.\n\n## Instructions\n\nThe canonical, full step-by-step workflow lives in\n[`.claude\/commands\/portaljs-add-resource.md`](https:\/\/github.com\/datopian\/portaljs\/blob\/main\/.claude\/commands\/portaljs-add-resource.md)\nin this repository \u2014 that file is the single source of truth. Read and follow it. Summary:\n\n1. Gather input (interview if thin): `DATASET` (slug or `namespace\/slug`), `SOURCE`\n   (path or URL), `PORTAL_DIR` (default `.`), `RESOURCE_NAME`, `RESOURCE_TITLE`,\n   `DESCRIPTION`. If `DATASET` or `SOURCE` is missing, list datasets from\n   `datasets.json` and ask.\n2. Validate the portal and locate the dataset entry by slug (and namespace, if\n   given). If the dataset does not exist, offer `\/portaljs-add-dataset` instead.\n3. Detect the format from extension\/Content-Type, fetch (check HTTP status) or\n   confirm the local path exists, then copy into `PORTAL_DIR\/public\/data\/` under a\n   non-colliding filename.\n4. Update `datasets.json`: if the dataset has no `resources` yet, migrate its\n   top-level `file`\/`format`\/`schema` into the first resource (lossless), then\n   append the new resource; if `resources` already exists, just append, keeping\n   `name` unique within the array.\n5. Verify the build with `npx next build`, capturing output to a log file; fix\n   malformed JSON before reporting success.\n6. Report the outcome (see Output below).\n\n## Output\n\n```\n\u2713 Resource added to DATASET: RESOURCE_TITLE (RESOURCE_NAME.EXT)\n  - Data file: public\/data\/RESOURCE_NAME.EXT\n  - Manifest:  datasets.json (dataset now has <n> resources)\n  - Showcase:  \/@<namespace>\/<slug> renders a section per resource\n```\n\nIf this was the first migration to multi-resource, note that the dataset's single\n`file` was moved into `resources[]` with no data lost.\n\n## Error Handling\n\n| Symptom | Cause | Fix |\n|---|---|---|\n| \"Dataset not found\" | `DATASET` slug\/namespace doesn't match any entry in `datasets.json` | List datasets from `datasets.json` and ask the user to pick, or run `\/portaljs-add-dataset` to create it |\n| `npx next build` fails with a JSON parse error | Manually edited `datasets.json` has a trailing comma or unescaped character | Re-open the file, fix the JSON, and rebuild before reporting success |\n| Resource file fails to fetch (non-2xx) | `SOURCE` URL is wrong, private, or the host is down | Confirm the URL in a browser or with `curl -I SOURCE`; ask for a corrected URL or a local path |\n| New resource's filename collides with an existing one in `\/public\/data` | Auto-derived `RESOURCE_NAME` matches an existing file stem | Pick a distinct `RESOURCE_NAME`, or let the skill append a numeric suffix |\n| Showcase doesn't render the new section after build | `name` in the new resource object duplicates an existing resource's `name` | Rename the resource's `name` to something unique within that dataset's `resources[]` |\n\n## Examples\n\n### Example 1 \u2014 Add a data dictionary to a single-file dataset\n\n```\n\/portaljs-add-resource orders .\/data\/orders-data-dictionary.csv --title \"Data dictionary\"\n```\n`orders` was a single CSV. It is migrated to a two-resource dataset (the original\ndata plus the dictionary), and its showcase now renders a section for each.\n\n### Example 2 \u2014 Add a resource by URL to a dataset that already has resources\n\n```\n\/portaljs-add-resource climate-observations https:\/\/example.org\/data\/methodology.json --name methodology --title \"Methodology notes\"\n```\nThe skill fetches the URL, checks the HTTP status, copies it to\n`public\/data\/methodology.json`, and appends it to the existing `resources[]` array.\n\n### Example 3 \u2014 Run with no arguments (interview mode)\n\n```\n\/portaljs-add-resource\n```\nWith no arguments, the skill lists datasets from `datasets.json`, asks which one to\nextend and for the new file's path or URL, then proceeds through steps 2-6 above.\n\n## Resources\n\n- [`.claude\/commands\/portaljs-add-resource.md`](https:\/\/github.com\/datopian\/portaljs\/blob\/main\/.claude\/commands\/portaljs-add-resource.md) \u2014 canonical workflow this skill follows\n- [`references\/reference.md`](references\/reference.md) \u2014 resource entry fields, single-to-multi-resource layout, troubleshooting\n- Related skills: `\/portaljs-add-dataset` (create a new dataset), `\/portaljs-define-schema` (describe a resource's fields)\n- [Frictionless Data \u2014 Data Package resources](https:\/\/datapackage.org\/standard\/data-resource\/) \u2014 the data model this feature mirrors\n","use_cases":["Add a data dictionary to a single-file dataset","Add a methodology document to an existing dataset","Add an additional data file to a dataset"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/datopian\/portaljs\/blob\/fc7ccd651459549a962c8b7aa08f60f8849fd9a5\/skills\/portaljs-add-resource\/SKILL.md","source_commit":"fc7ccd651459549a962c8b7aa08f60f8849fd9a5","license":"MIT","version":"1.0.0","listing_approved_at":"2026-11-22","created_at":"2026-11-21T15:51:23.000000Z","updated_at":"2026-11-22T11:18:24.000000Z","seo_title":"Add Resource to PortalJS Dataset","seo_description":"Add a file to an existing dataset in a PortalJS portal. Ideal for adding data dictionaries, methodology docs, or additional data files.","seo_keywords":["Add resource to dataset","PortalJS dataset extension","Add data dictionary","Add methodology document","PortalJS resource addition"]}}