Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/data/tags.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"id": 1,
"name": "One"
},
{
"id": 2,
"name": "Two"
}
]
62 changes: 54 additions & 8 deletions src/data/taxonomies.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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": {
Expand Down
34 changes: 32 additions & 2 deletions src/globals/api-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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/',
Expand Down
18 changes: 12 additions & 6 deletions src/globals/fake-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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': [{}],
},
},
};
Expand Down