diff --git a/src/data/tags.json b/src/data/tags.json new file mode 100644 index 0000000..6638de7 --- /dev/null +++ b/src/data/tags.json @@ -0,0 +1,10 @@ +[ + { + "id": 1, + "name": "One" + }, + { + "id": 2, + "name": "Two" + } +] diff --git a/src/data/taxonomies.json b/src/data/taxonomies.json index 2e28444..78b3257 100644 --- a/src/data/taxonomies.json +++ b/src/data/taxonomies.json @@ -3,10 +3,33 @@ "name": "Categories", "slug": "category", "description": "", - "types": [ - "post" - ], - "visibility": { "show_ui": false }, + "labels": { + "name": "Categories", + "singular_name": "Category", + "search_items": "Search Categories", + "popular_items": null, + "all_items": "All Categories", + "parent_item": "Parent Category", + "parent_item_colon": "Parent Category:", + "edit_item": "Edit Category", + "view_item": "View Category", + "update_item": "Update Category", + "add_new_item": "Add New Category", + "new_item_name": "New Category Name", + "separate_items_with_commas": null, + "add_or_remove_items": null, + "choose_from_most_used": null, + "not_found": "No categories found.", + "no_terms": "No categories", + "items_list_navigation": "Categories list navigation", + "items_list": "Categories list", + "most_used": "Most Used", + "back_to_items": "← Back to Categories", + "menu_name": "Categories", + "name_admin_bar": "category" + }, + "types": ["post", "page"], + "visibility": { "show_ui": true }, "hierarchical": true, "rest_base": "categories", "_links": { @@ -33,10 +56,33 @@ "name": "Tags", "slug": "post_tag", "description": "", - "types": [ - "post" - ], - "visibility": { "show_ui": false }, + "labels": { + "name": "Tags", + "singular_name": "Tag", + "search_items": "Search Tags", + "popular_items": "Popular Tags", + "all_items": "All Tags", + "parent_item": null, + "parent_item_colon": null, + "edit_item": "Edit Tag", + "view_item": "View Tag", + "update_item": "Update Tag", + "add_new_item": "Add New Tag", + "new_item_name": "New Tag Name", + "separate_items_with_commas": "Separate tags with commas", + "add_or_remove_items": "Add or remove tags", + "choose_from_most_used": "Choose from the most used tags", + "not_found": "No tags found.", + "no_terms": "No tags", + "items_list_navigation": "Tags list navigation", + "items_list": "Tags list", + "most_used": "Most Used", + "back_to_items": "← Back to Tags", + "menu_name": "Tags", + "name_admin_bar": "post_tag" + }, + "types": ["post", "page"], + "visibility": { "show_ui": true }, "hierarchical": false, "rest_base": "tags", "_links": { diff --git a/src/globals/api-routes.js b/src/globals/api-routes.js index 1e1b039..70ea15e 100644 --- a/src/globals/api-routes.js +++ b/src/globals/api-routes.js @@ -5,6 +5,7 @@ import { mediaList, createMedia } from './fake-media.js'; import users from '../data/users'; import taxonomies from '../data/taxonomies'; import categories from '../data/categories'; +import tags from '../data/tags'; import types from '../data/types'; import themes from '../data/themes'; @@ -176,12 +177,41 @@ export default [ // Categories { path: '/wp/v2/categories', - method: '*', + method: 'GET', handler () { - return categories; + return new window.Response(JSON.stringify(categories)); + }, + }, + { + path: '/wp/v2/categories', + method: 'POST', + handler ({ payload: { name } }) { + return { + id: window.lodash.random(1, 100000000), + name, + }; }, }, + // Tags + { + path: '/wp/v2/tags', + method: 'GET', + handler () { + return new window.Response(JSON.stringify(tags)); + }, + }, + { + path: '/wp/v2/tags', + method: 'POST', + handler ({ payload: { name } }) { + return { + id: window.lodash.random(1, 100000000), + name, + }; + }, + }, + // Users { path: '/wp/v2/users/', diff --git a/src/globals/fake-data.js b/src/globals/fake-data.js index 33e1233..7b24574 100644 --- a/src/globals/fake-data.js +++ b/src/globals/fake-data.js @@ -23,13 +23,16 @@ export const pages = { theme_style: true, type: 'page', link: `${window.location.origin}/preview`, - categories: [ ], + categories: [1], + tags: [1, 2], featured_media: 0, permalink_template: `${window.location.origin}/preview`, preview_link: `${window.location.origin}/preview`, _links: { - 'wp:action-assign-categories': [], - 'wp:action-create-categories': [], + 'wp:action-create-categories': [{}], + 'wp:action-assign-categories': [{}], + 'wp:action-create-tags': [{}], + 'wp:action-assign-tags': [{}], }, }, post: { @@ -54,13 +57,16 @@ export const pages = { theme_style: true, type: 'post', link: `${window.location.origin}/preview`, - categories: [ ], + categories: [1], + tags: [1, 2], featured_media: 0, permalink_template: `${window.location.origin}/preview`, preview_link: `${window.location.origin}/preview`, _links: { - 'wp:action-assign-categories': [], - 'wp:action-create-categories': [], + 'wp:action-create-categories': [{}], + 'wp:action-assign-categories': [{}], + 'wp:action-create-tags': [{}], + 'wp:action-assign-tags': [{}], }, }, };