Skip to content
Merged
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
9 changes: 5 additions & 4 deletions src/components/metadata/MetaSimple.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@ export class MetaSimple extends Component {
);
}

renderTagsInput() {
renderTagsInput(key) {
const { fieldValue, nameAttr, updateFieldValue, siteMeta } = this.props;
const siteTags = (siteMeta && siteMeta.tags) || [];
const suggestions = (siteMeta && siteMeta[key]) || [];

return (
<MetaTags
fieldValue={fieldValue}
nameAttr={nameAttr}
updateFieldValue={updateFieldValue}
suggestions={siteTags}
suggestions={suggestions}
/>
);
}
Expand All @@ -122,7 +122,8 @@ export class MetaSimple extends Component {
node = this.renderStaticFilePicker();
break;
case 'tags':
node = this.renderTagsInput();
case 'categories':
node = this.renderTagsInput(fieldKey);
break;
default:
node = this.renderEditable();
Expand Down
2 changes: 1 addition & 1 deletion src/components/metadata/MetaTags.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default class MetaTags extends Component {
if (!(pageTags instanceof Array)) {
return (
<span className="meta-error">
Invalid array of tags! Found: <strong>{pageTags}</strong>
Expected an array of items. Found: <strong>{pageTags}</strong>
<br />
<span onClick={() => this.rectifyTag(pageTags)}>Click here</span>
to correct.
Expand Down
2 changes: 1 addition & 1 deletion src/components/metadata/tests/metatags.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('Components::MetaTags', () => {
...defaultProps,
fieldValue: 'foo',
});
const error = 'Invalid array of tags! Found: fooClick hereto correct.';
const error = 'Expected an array of items. Found: fooClick hereto correct.';
const error_element = component.find('.meta-error');
const rectifier = error_element.find('span').last();

Expand Down
2 changes: 1 addition & 1 deletion src/utils/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export const injectDefaultFields = (config, path, type, front_matter = {}) => {
*/
export const computeFieldType = (value, key = null) => {
let type = 'simple';
const specialKeys = ['tags'];
const specialKeys = ['tags', 'categories'];
if (specialKeys.includes(key) && _.isArray(value)) return type;

if (_.isObject(value)) type = 'object';
Expand Down