{"id":18561258,"url":"https://github.com/apostrophecms/import-a2-tags","last_synced_at":"2025-05-15T16:34:08.782Z","repository":{"id":181033640,"uuid":"666107689","full_name":"apostrophecms/import-a2-tags","owner":"apostrophecms","description":"Import tags from A2 to tag piece types corresponding to various piece and page types in your project","archived":false,"fork":false,"pushed_at":"2023-07-20T13:37:34.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-08T10:54:56.171Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apostrophecms.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-13T18:21:20.000Z","updated_at":"2023-07-13T19:05:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"12edab48-6c71-4704-b347-76f1dc1a4920","html_url":"https://github.com/apostrophecms/import-a2-tags","commit_stats":null,"previous_names":["apostrophecms/import-a2-tags"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apostrophecms%2Fimport-a2-tags","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apostrophecms%2Fimport-a2-tags/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apostrophecms%2Fimport-a2-tags/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apostrophecms%2Fimport-a2-tags/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apostrophecms","download_url":"https://codeload.github.com/apostrophecms/import-a2-tags/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254377624,"owners_count":22061187,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T22:06:22.462Z","updated_at":"2025-05-15T16:34:08.750Z","avatar_url":"https://github.com/apostrophecms.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `@apostrophecms/import-a2-tags`\n\n## Purpose\n\nWhile Apostrophe 2 documents have a `tags` array field, this field doesn't exist in\nApostrophe 3. Instead, tags are represented as relationships to a \"tag piece type\" if\nand when this is desired in a particular project.\n\nThis module provides a simple way to migrate A2-style, array-based `tags` properties to\nA3-style relationships to a \"tag piece type\" corresponding to a particular piece type, or\nto pages.\n\nThis module is most often used after a successful run of `@apostrophecms/content-upgrader`,\nwhich copies the `tags` array property of each document over to A3 without modification.\n\n## Installation\n\n```bash\nnpm install @apostrophecms/import-a2-tags\n```\n\n## Configuration\n\nNote that in this example we are configuring tags for all page types, but you can also import\ntags for any piece type or individual page type in the same way.\n\nYou can also add tags to *all* piece types by configuring them for `@apostrophecms/piece-type`,\nbut usually this is a mistake because you will want to curate the tags for each piece type\nseparately.\n\n```javascript\n// in app.js\nmodules: {\n  // Create a \"tag piece type\" to hold the tags in A3, since\n  // A3 does not use arrays for tags.\n  //\n  // For images and files you can skip this\n  'page-tag': {},\n  // Activate the import-a2-tags module\n  '@apostrophecms/import-a2-tags': {}\n}\n\n// in modules/page-tag/index.js (for images and files you can skip this)\nmodule.exports = {\n  extend: '@apostrophecms/piece-type'\n},\n\n// in modules/@apostrophecms/page-type/index.js (for images and files you can skip this)\nmodule.exports = {\n  fields: {\n    add: {\n      _tags: {\n        type: 'relationship',\n        withType: 'page-tag',\n        label: 'Tags',\n        help: 'Tags for this page'\n      }\n    }\n  }\n};\n```\n\n## Usage\n\n```bash\n# Import tags on images to the built-in image-tag piece type and create relationships\nnode app @apostrophecms/import-a2-tags:import --types=@apostrophecms/image:@apostrophecms/image-tag\n# Requires additional configuration, see above\nnode app @apostrophecms/import-a2-tags:import --types=@apostrophecms/page-type:page-tag\n```\n\n### Specifying the piece type or page type to import tags from\n\nThe type before the `:` is the page or piece type that has data in an existing `tags` array\nproperty in MongoDB (usually due to an import from A2).\n\n### Specifying the \"tag piece type\" to represent the tags\n\nSince A3 does not have array-based tags, you'll need to add a piece type to your project\nto represent the tags. This change was made in A3 because it yields a better curation\nexperience.\n\nThe type after the `:` is a piece type that you have added to your A3 project to serve as a\n\"tag type.\" You must also add a `_tags` relationship pointing at this type, as shown above.\n\nNote that images already have a tag piece type, `@apostrophecms/image-tag`, and\nfiles do too, `@apostrophecms/file-tag`. You don't have to create a new module in order\nto import these.\n\n## Importing multiple types at once\n\nIf you wish, you can specify multiple comma-separated pairs of types:\n\n```bash\nnode app @apostrophecms/import-a2-tags:import --types=type1:type1-tag,type2:type2-tag\n```\n\nAgain, the tag piece types must exist in your project, except for\n`@apostrophecms/image-tag` and `@apostrophecms/file-tag` which exist by default.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapostrophecms%2Fimport-a2-tags","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapostrophecms%2Fimport-a2-tags","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapostrophecms%2Fimport-a2-tags/lists"}